How to use Actions class in Selenium Webdriver?

0 votes

Why do we need Actions class and what is the use of it if it is not used ever in the code.
Below is the code I took from other site.

public class SwitchFrames {

   public static void main(String... args) {
      WebDriver driver = new FirefoxDriver();
      driver.get("file://C:/Frames.html");

      Actions action = new Actions(driver);

      driver.switchTo().frame(0);
      WebElement txt = driver.findElement(By.name("1"));
      txt.sendKeys("Frames Works");

      driver.switchTo().defaultContent();

      driver.switchTo().frame(1);
      txt = driver.findElement(By.name("2"));
      txt.sendKeys("Frames always works");
   }

}

Apr 4, 2018 in Selenium by Ashish
• 2,630 points
2,436 views

1 answer to this question.

0 votes
In seleniun webdriver it is not mandatory or it is not required to use actions
always or it is not like that it is not used ever but the use of actions class as switching to frame or using
alert is different and using Actions is different concept.

You can try using different functions of Actions class http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/interactions/Actions.html
and for switch is used to shift the control of webdirver from one page to another or one frame to another
answered Apr 4, 2018 by Damon Salvatore
• 5,510 points

Related Questions In Selenium

0 votes
1 answer

How to use webdriver in selenium?

In Java, in order to call the ...READ MORE

answered Dec 20, 2018 in Selenium by Shuvodip
76 views
0 votes
1 answer

How to use firefox webdriver (geckodriver) in selenium?

Firefox v47+ with selenium 2.53, you need ...READ MORE

answered Jan 8 in Selenium by Nabarupa
1,109 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,090 points
548 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
881 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
546 views
0 votes
1 answer

Double click a record in a grid using Selenium webdriver

Try Actions class to perform this Actions action ...READ MORE

answered Mar 29, 2018 in Selenium by Damon Salvatore
• 5,510 points
978 views
0 votes
1 answer

Handling Alerts Selenium Webdriver

You can use Explicit Wait from here https://www.seleniumhq.org/docs/04_webdriver_advanced.jsp#explicit-and-implicit-waits public ...READ MORE

answered Apr 9, 2018 in Selenium by Damon Salvatore
• 5,510 points
226 views