[英]Not able to do mouse over operation using selenium webdriver
Below is the code 下面是代码
WebDriver dr= new ChromeDriver();
dr.get("http://obsessory.com/");
dr.findElement(By.xpath("html/body/header/div[2]/div[1]/ul/li[1]/a")).click();
dr.findElement(By.id("email")).sendKeys("username@gmail.com");
dr.findElement(By.name("LoginForm[password]")).sendKeys("password");
dr.findElement(By.xpath(".//[@id='signIn']/div[2]/div[3]/div[3]/input")).click();
Actions action = new Actions(dr);
WebElement we = dr.findElement(By.xpath("html/body/header/div[2]/div[1]/ul/li[4]/a/span"));
action.moveToElement(we).moveToElement(dr.findElement(By.xpath("html/body/header/div[2]/div[1]/ul/li[4]/ul/li[1]/a"))).click().build().perform();
I wanted to click on 'my accounts' or any of those other links. 我想点击“我的帐户”或其他任何链接。 Kindle tell me how to do that
Kindle告诉我该怎么做
Try with 试试看
Actions action= new Actions(dr);
WebElement we = dr.findElement(By.xpath("html/body/header/div[2]/div[1]/ul/li[4]/a/span"));
action.moveToElement(we).perform();
By locator = By.xpath("html/body/header/div[2]/div[1]/ul/li[4]/ul/li[1]/a");
dr.click(locator);
@kavya @kavya
Please try this code. 请尝试此代码。 I think you are not able to type password in password textbox.
我认为您无法在密码文本框中输入密码。
For password: 密码:
dr.findElement(By.xpath("(//input[@id='email'])[2]")).sendKeys("obsessory");
For Menu: 对于菜单:
WebElement we = dr.findElement(By.xpath("html/body/header/div[2]/div[1]/ul/li[4]/a"));
WebElement ve = dr.findElement(By.xpath("html/body/header/div[2]/div[1]/ul/li[4]/ul/li[1]/a"));
Actions act = new Actions(dr);
act.moveToElement(we).click(ve).perform();
Hope this will work 希望这会起作用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.