gpt4 book ai didi

java - 无法单击选项卡的子值,在 Selenium 中出现 'element not visible' 异常

转载 作者:行者123 更新时间:2023-11-30 06:08:57 24 4
gpt4 key购买 nike

尝试单击“http://toolsqa.com/”中“演示站点”选项卡中的“电子商务演示站点” ' 网站使用下面提到的方式。但无法点击它。请帮助我解决这个问题。

代码1:

 WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.linkText("E-Commerce Demo Site"))));
driver.findElement(By.linkText("E-Commerce Demo Site")).click();

代码2:

driver.findElement(By.cssSelector("#main-nav > li.menu-item.menu-item-type-custom.menu-item-object-custom.menu-item-has-children.menu-item-17611.dt-mega-menu.mega-auto-width.mega-column-1.has-children > ul > li.menu-item.menu-item-type-custom.menu-item-object-custom.menu-item-21575.dt-mega-parent.wf-1.first.level-arrows-on")).click();

代码3:

WebElement subNav = driver.findElement(By.className("sub-nav"));
List < WebElement > subNavValues = subNav.findElements(By.tagName("li"));

subNavValues.get(0).click();

最佳答案

     Actions ac;
ac = new Actions(dr);
ac.MoveToElement(dr.FindElement(By.LinkText("DEMOSITES"))).Perform();

然后使用以下任意 xpath 单击子菜单:

1."//span[contains(text(),'电子商务演示站点')]"

2."//a[@href=' http://store.demoqa.com ']"

dr.findelement(By.xpath(xpath)).click();

关于java - 无法单击选项卡的子值,在 Selenium 中出现 'element not visible' 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39035872/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com