场景:
答案 0 :(得分:0)
这是使用Actions
类'来处理的。硒中的moveToElement()
方法;
WebElement orders=driver.findElement(By.xpath("\\xpath\to\your\orders\element"));
WebElement Accessioning=driver.findElement(By.xpath("\\xpath\to\your\orders\element"));
action.moveToElement(orders).moveToElement(Accessioning).build().perform();
<强>更新:强>
driver.manage().window().maximize();
driver.get("http://biotdev.technossustest.com/Workflow/Worklist2.aspx");
driver.findElement(By.cssSelector("#ctl00_LoginContent_MainLogin_UserName")).sendKeys("hmeyer");
driver.findElement(By.cssSelector("#ctl00_LoginContent_MainLogin_Password")).sendKeys("spivulet");
driver.findElement(By.cssSelector("#ctl00_LoginContent_MainLogin_LoginImageButton")).click();
Thread.sleep(10000);
driver.findElement(By.cssSelector("#ctl00_PassowrdChangeNotification_OkPushButton")).click();
Thread.sleep(10000);
Actions action = new Actions(driver);
WebElement menuItem = driver.findElement(By.cssSelector("#ctl00_MainMenun5 > table"));
WebElement subMenu = driver.findElement(By.cssSelector("#ctl00_MainMenun23 > td > table > tbody > tr > td > a"));
action.moveToElement(menuItem).build().perform();
Thread.sleep(5000);
action.moveToElement(subMenu).click().build().perform();
答案 1 :(得分:0)
我已经尝试了这个并且已经解决了,谢谢Kushal的帮助。
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.id("ctl00_DefaultContent_WorklistCtrl_WorklistTable")));
WebElement menu = wait.until(ExpectedConditions.visibilityOfElementLocated((By.xpath("//*[@id='ctl00_MainMenun5']//td[2]"))));
Actions action = new Actions(driver);
action.clickAndHold(menu).build().perform();
WebElement item = driver.findElement(By.xpath("//*[@id='ctl00_MainMenun23']//a[text()='Accessioning']"));
item.click();
答案 2 :(得分:0)
尝试使用Robot类......
Point coordinates = driver.findElement(By.xpath/id(xpathString/id)).getLocation();
Robot robot = new Robot();
robot.mouseMove(coordinates.getX(),coordinates.getY());
以上代码不适用于无头环境。