Thank you CK76 for your help, unfortunately, that did not provide the solution.
As long as the movement is within the screen (X1 < 15), everything goes well. If it falls outside the screen, the screen will scroll to the correct position but the movement will not take place.
This is my full code, Would you mind taking a look at what's going wrong?
Sub TestVidsVerplaatsen()
'sort videos into Kinomap playlist
Dim Telby As Integer, X3 As Integer
Dim by As New Selenium.by
Dim elePak As WebElement, elePlak As WebElement
Dim bot As New ChromeDriver
With bot
'.AddArgument ("headless")
'this hides the Chrome window when it is not inhibited
.AddArgument "window-size=600,800"
'When logging in, the chrome screen is small
url = login page
'login page
.Get url
Telby = 0
Do
Telby = Telby + 1
.Wait (20)
DoEvents
Loop Until Telby = 100 Or .IsElementPresent(by.xpath("/html/body/app-root/app-marketing/app-login/div/div/div/form/section/div[1]/div/div/input"))
'wait until input field is present
If Telby = 100 Then got Fout
.FindElementByXpath("/html/body/app-root/app-marketing/app-login/div/div/div/form/section/div[1]/div/div/input").SendKeys (MyMail)
.FindElementByXpath("/html/body/app-root/app-marketing/app-login/div/div/div/form/section/div[2]/div/div/input").SendKeys (MyPass)
.FindElementByXpath("/html/body/app-root/app-marketing/app-login/div/div/div/form/section/div[3]/div/button").Submit
'now you are logged in
Telby = 0
Do
Telby = Telby + 1
.Wait (20)
DoEvents
Loop Until Telby = 100 Or .IsElementPresent(by.xpath("/html/body/app-root/app-dashboard/div[2]/app-breadcrumb/div/div/div/div/div"))
'the Dashboard button is now present, but we do NOT click on it. only to wait for the page to load
.Window.maximize
'make Chrome full screen
S = URL & Number Playlist
.Get S
'tested using msgbox and now element for eleplak is already present, even without ScrollIntoView
Do Until InStr(1, .url, Right(S, 5)) > 0
'Here we cannot check for web element so check for the URL
.Wait (100)
DoEvents
Loop
On Error GoTo Fout
.FindElementByXpath("/html/body/div[2]/div/a[2]").Click
'accept cookies
X = 2
'location of source elepak element
X1 = 12
'location of destination eleplak element
.FindElementByXpath("/html/body/div[5]/div[3]/div/div/ul/li[" & X & "]").ScrollIntoView
'put elepak at the bottom of the screen because it is FALSE, if TRUE it is at the top of the screen
Set elePak = .FindElementByXpath("/html/body/div[5]/div[3]/div/div/ul/li[" & X & "]")
'put element to be moved in elePak
.Wait (100)
.FindElementByXpath("/html/body/div[5]/div[3]/div/div/ul/li[" & X1 & "]").ScrollIntoView
Set elePlak = .FindElementByXpath("/html/body/div[5]/div[3]/div/div/ul/li[" & X1 & "]")
'put the position where elepak should go in eleplak
.Wait (100)
.actions.DragAndDrop(elePak, elePlak).Perform
'the page scrolls to the correct position but does not move when elePlak falls outside the screen, even using ScrollIntoView True or ScrollIntoView False
DoEvents
.FindElementByXpath("/html/body/div[5]/div[3]/div/button").Click
'Confirm new order
MsgBox Left(elePak.Text, 30) & " = moved, just below " & vbLf & Left(elePlak.Text, 30)
'check if element has been moved
Einde:
.Quit
'close Chrome
End With
Exit Sub
Fout:
bot.Quit
Err.Clear
MsgBox "An error has occurred " & Err.Number
End Sub
Bookmarks