java - How to "hover over" the button in selenium? -


this question has answer here:

how add hover element? consider below code:

package automationframework;  import java.util.concurrent.timeunit;  import org.openqa.selenium.*;  import org.openqa.selenium.firefox.firefoxdriver;  public class loginpage {      private static webdriver driver = null;      public static void main(string[] args) {          // create new instance of firefox driver          driver = new firefoxdriver();          //put implicit wait          driver.manage().timeouts().implicitlywait(10, timeunit.seconds);          //launch website          driver.get("url");          // find element that's id attribute 'account'(my account)          // driver.findelement(by.xpath("/html/body/table/tbody/tr[5]/td/table/tbody/tr/td[2]/form/table/tbody/tr[3]/td[2]/input")).click();          // enter username on element           driver.findelement(by.name("username")).sendkeys("remote");           // find element that's id attribute 'pwd' (password)          driver.findelement(by.name("password")).sendkeys("aaaaaa");          // submit form. webdriver find form element           driver.findelement(by.name("submit")).click();          // print log in message screen          system.out.println(" login successfully");         driver.findelement(by.name("img2")).click();          // find element that's id attribute 'account_logout' (log out)          //driver.findelement (by.name("img104")).click();          // close driver          driver.quit();              }      } 

go action class.

actions hover = new actions(driver);  webelement elem_to_hover = driver.findelementby(by.id("id"));  hover.movetoelement(elem_to_hover);  hover.build();  hover.perform(); 

Comments

Popular posts from this blog

c++ - OpenMP unpredictable overhead -

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

javascript - Wordpress slider, not displayed 100% width -