Java 如何使用SeleniumWebDriver查找动态元素?
您可以在webdriver的id帮助下单击,直到元素能够接收到单击Java 如何使用SeleniumWebDriver查找动态元素?,java,html,selenium,selenium-webdriver,selenium-ide,Java,Html,Selenium,Selenium Webdriver,Selenium Ide,您可以在webdriver的id帮助下单击,直到元素能够接收到单击 wd.get(urlSubpage); wd.findElement(By.cssSelector("[class='widgetLabel']")); 用JS点击 试着用ChroPath之类的东西对其进行部分调试…要查找哪个元素?html中没有widgetLabel类。@Muzzamil I want find I added,但原因是:org.openqa.selenium.NoSuchElementExc
wd.get(urlSubpage);
wd.findElement(By.cssSelector("[class='widgetLabel']"));
用JS点击
试着用ChroPath之类的东西对其进行部分调试…要查找哪个元素?html中没有widgetLabel类。@Muzzamil I want find I added,但原因是:org.openqa.selenium.NoSuchElementException:找不到元素:button\-body@Nirwellyn请尝试用JS单击,如回答中所述。复制粘贴代码并重试。删除“单击前等待”元素
wd.get(urlSubpage);
wd.findElement(By.cssSelector("[class='widgetLabel']"));
WebDriverWait wait = new WebDriverWait(driver, 50);
wait.until(ExpectedConditions.elementToBeClickable(By.id("button-body")));
WebElement element = driver.findElement(By.id("button-body"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);