Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用SeleniumWebDriver查找动态元素?_Java_Html_Selenium_Selenium Webdriver_Selenium Ide - Fatal编程技术网

Java 如何使用SeleniumWebDriver查找动态元素?

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

您可以在webdriver的id帮助下单击,直到元素能够接收到单击

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);