我有一个网站,我正在尝试自动化我可以登录并点击其中一个菜单,但是当我点击第三个孩子时我遇到了问题
假设我有一个主菜单,它显示子菜单,单击子菜单它显示第三个菜单,其中有 10 个以自上而下的顺序显示的链接,我点击了我无法执行的第 9 个子菜单。
下面是代码:
WebElement myElement1 = driver.findElement(By.xpath("/html/body/form/div[5]/div/div[2]/table/tbody/tr/td[2]/div/div/ul/li/ul/li[2]/span/span/span"));
Actions builder = new Actions(driver);
builder.moveToElement(myElement1).build().perform();
myElement1.click();
WebElement myElement2 = driver.findElement(By.xpath("/html/body/form/div[5]/div/div[2]/table/tbody/tr/td[2]/div/div/ul/li/ul/li[2]/ul/li/span/span/span"));
Actions builder1 = new Actions(driver);
builder1.moveToElement(myElement2).build().perform();
myElement2.click();
WebDriverWait wait = new WebDriverWait(driver, 40);
WebElement ele = driver.findElement(By.xpath("/html/body/form/div[5]/div/div[2]/table/tbody/tr/td[2]/div/div/ul/li/ul/li[2]/ul/li/ul/li[9]/a/span/span"));
System.out.println(ele.getText());
WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("/html/body/form/div[5]/div/div[2]/table/tbody/tr/td[2]/div/div/ul/li/ul/li[2]/ul/li/ul/li[9]/a/span/span")));
System.out.println(" about to get enter time sheet" + element.getText());
System.out.println(isElementPresent(By.xpath("/html/body/form/div[5]/div/div[2]/table/tbody/tr/td[2]/div/div/ul/li/ul/li[2]/ul/li/ul/li[9]/a/span/span")));
driver.manage().timeouts().implicitlyWait(2500, TimeUnit.SECONDS);
org.openqa.selenium.Point coordinates = driver.findElement(By.xpath("/html/body/form/div[5]/div/div[2]/table/tbody/tr/td[2]/div/div/ul/li/ul/li[2]/ul/li/ul/li[9]/a/span/span")).getLocation();
System.out.println(coordinates.getX() + " " + coordinates.getY());
WebElement myElement3 = driver.findElement(By.xpath("/html/body/form/div[5]/div/div[2]/table/tbody/tr/td[2]/div/div/ul/li/ul/li[2]/ul/li/ul/li[9]/a/span/span"));
Actions builder3 = new Actions(driver);
builder3.moveToElement(myElement3).build().perform();
myElement3.click();
最后一个下拉列表是失败的地方。