Selenium Actions not working with version 3.141.59

Tyler Pranger :

The main issue is that we are trying to update our POM to use version 3.141.59 of Selenium. During our update we noticed that we have several errors with Actions. Upon reading documentation we found that:

"import org.openqa.selenium.interactions.Actions;" has been deprecated and replaced with "import org.openqa.selenium.interactions.Action".

We want to keep the same behavior and update our code to work with the new import. We have not seen any new documentation of how to actually use it. Below is an example of how we were using the old Actions.

try {
       Actions actions = new Actions(driver);
       actions.moveToElement(searchDocument);
       actions.sendKeys(PDF);
       Thread.sleep(1000);
       actions.build().perform();
    }  catch(Exception e) {
}

I was able to find this note in the change logs on Selenium:

Deprecated the original Actions API in favour of the W3C approach.

supputuri :

Here is the simple example if it's helpful.

Actions actions = new Actions(driver);

// create the mouserover action
Action mouseOverOnElement = actions.moveToElement(linkMenu).build();

// get the back ground color before mouse over             
String bgColor = linkMenu.getCssValue("background-color");
System.out.println("Before hover: " + bgColor);

// perform the mouseover operation        
mouseOverOnElement.perform();    

// get the back ground color after mouse over       
bgColor = linkMenu.getCssValue("background-color");
System.out.println("After hover: " + bgColor);

Selenium Doc: https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/interactions/Action.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=83883&siteId=1