javaselenium-webdriversafari

Im having hard time with Safari Webdriver and clicking on a web element


Im struggling with Safari Webdriver and clicking elements on a page. To start I have up-2-date selenium version as stated on apples website. For context I'm running selenium on a mac machine with selenium java on Safari.
To click a web elements what I have tried so far example 1

JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();",cartBtn);

Debugging the code just moves on failing or doing any click actions. I've tried to check if safari webdriver is able to see the webelement by using isDisplayed

Tried Actions class example 2:

actions.moveToElement(cartBtn).build().perform();
actions.sendKeys(Keys.RETURN).build().perform();

throws an exception:

org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: Build info: version: '4.22.0', revision: 'c5f3146703*'

I have tried debug and also tried to wait for the page to load just in case if that was reason for MoveTargetOutOfBoundsException Im trying to see if anyone else has been in similar situation and what other strategies they used. Just want to say I hate automating in Safari never had this many issues in chrome/firefox.


Solution

  • I was able to figure it out I played around with my locator/xpath more and it started to work. My locators worked for Chrome/Firefox but refused to work with Safari.

    Did I mention how much safari sucks?