Reputation: 438
So some weird stuff, could just be im unfamiliar with a specific rule related to the MoveByOffset() method. So I have the x and y coordinates that I need to move the mouse too, I know they're the right coordinates because I can actually see it happen when my test reaches this line of code:
actions.MoveByOffset(842, 663).Click().Perform();
The problem arises when I interact with a separate element, I click a button to open a drawer to validate some information, Once my script validates what it needs to it closes the drawer and attempts to execute
actions.MoveByOffset(842, 663).Click().Perform();
once again.
I dont scroll or really change anything on the screen other than open a drawer and close it.
But Its at this point where ill get the exception OpenQA.Selenium.WebDriverException : move target out of bounds I have it currently in a try catch block and even when I catch the exception it still throws the same exception at me.
Any help or advice or info would be appreciated
Upvotes: 1
Views: 9137
Reputation: 91
MoveByOffset(x, y)
means Move By Offset from your current position.
Performing MoveByOffset(xOff, yOff)
you move pointer into (currentX+xOff; currentY+yOff)
.
So first time it is 0+842 and 0+663, second time it is 842+842 and 663+663.
If you need to go to element use moveToElement()
.
To be sure you don't reach bounds of viewport you can use something like driver.manage().window().getSize()
.
it is Java code, but I believe c# has such operators.
Upvotes: 7