Selenium with java-需要单击a中的按钮<;部门>&书信电报;ul>&书信电报;李>;?
我需要点击位于标签中的按钮。 我需要用classSelenium with java-需要单击a中的按钮<;部门>&书信电报;ul>&书信电报;李>;?,java,selenium,Java,Selenium,我需要点击位于标签中的按钮。 我需要用classclass=“icon link exp icon放大”单击第三个列表 css选择器将是: a[title='Voer zoekactie uit'][href*='Search.mvc'][class*='magnify'] 尝试在代码中添加显式等待以提高稳定性 WebDriverWait wait = new WebDriverWait(driver,10); WebElement button = wait.until(Expecte
class=“icon link exp icon放大”单击第三个列表
-
css选择器将是:
a[title='Voer zoekactie uit'][href*='Search.mvc'][class*='magnify']
尝试在代码中添加显式等待以提高稳定性
WebDriverWait wait = new WebDriverWait(driver,10);
WebElement button = wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("a[title='Voer Zoekactie uit'][href*='Search.mvc'][class*='magnify']")));
button.click();
使用WebdriverWait
和elementtobelickable
以及以下xpath来单击元素
WebDriverWait wait=new WebDriverWait(driver,40);
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@class='navbar navbar-blue']//ul[contains(@class,'nav navbar-nav')]//li//a[@class='icon-link exp-icon-bell'][@title='Wachten op Melding']"))).click();
driver.switchTo().frame("ifrUserTools");
如果您想使用cssselector,请尝试
WebDriverWait wait=new WebDriverWait(driver,40);
wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("div.navbar.navbar-blue ul.nav.navbar-nav li.disabled a.icon-link.exp-icon-bell[title='Wachten op Melding']"))).click();
编辑
首先切换到iframe
,然后使用上述代码访问元素
WebDriverWait wait=new WebDriverWait(driver,40);
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@class='navbar navbar-blue']//ul[contains(@class,'nav navbar-nav')]//li//a[@class='icon-link exp-icon-bell'][@title='Wachten op Melding']"))).click();
driver.switchTo().frame("ifrUserTools");
这是CSS
a.icon-link.exp-icon-.magnify
如果要包括下面的层次结构检查
div.navbar.navbar-blue ul a.icon-link.exp-icon-.magnify
帮助所有人
这起到了作用:
等待.until(ExpectedConditions.FrameToBeavailable并切换到IT(“ifrUserTools”);
wait.until(ExpectedConditions.element可选择(由.cssSelector(“[href*='Search.mvc'][class*='magnize']));
WebElement searchButton=driver.findElement(由.cssSelector(“[href*='Search.mvc']][class*='magnize']”)创建);
搜索按钮。单击() 您可以找到这样的元素
By.xpath(""//ul[@class='navbar-nav'//li[3]]");
请尝试使用上述代码,并让我知道您尝试了哪些选择器字符串?可能存在iframe,它可能会阻止访问元素。您是否可以检查您发布的元素上方是否存在iframe。无ifram。在div和i see之间有一个和一些脚本我发现了一个i帧你是对的。。。那现在呢?没有经验this@YalcinBatur:选中编辑选项。首先切换到iframe,然后使用上面的代码。希望这能解决您的问题。等待.until(ExpectedConditions.elementtobelickable(By.cssSelector)(“a.icon-link.exp-icon-.放大”);WebElement searchButton=driver.findElement(By.cssSelector(“a.icon-link.exp-icon-.放大”);搜索按钮。单击();不工作:(您是否正在获取NoTouchElement expectpion?在此处发布错误。未加载驱动程序…预期条件失败:等待元素可单击:By.css选择器:div.navbar.navbar-blue ul a.icon-link.exp icon-.放大(尝试20秒,间隔500毫秒)好的,第一件事。你检查过我在屏幕截图中显示的在chrome浏览器开发工具中工作的css了吗?天哪,很抱歉这些不工作。我发现这些1/1 a[title='Voer zoekactie uit'][class*='Voer zoekactie'][class*='magnize']和这个[href*='Search.mvc'][class*='magnize']评论不用于扩展讨论;这段对话已经结束。