如何使用硒webdriver查找动态元素?

问题描述 投票:-4回答:1
<div id="button" data-testid="widgetButton" class=" chat-closed mobile-size__large">

我具有Webdriver无法找到的带有特殊字符的元素。

我正在尝试点击一个项目,我已经尝试了所有方法。我的最后尝试:

wd.get(urlSubpage);
        wd.findElement(By.cssSelector("[class='widgetLabel']"));
java html selenium selenium-webdriver selenium-ide
1个回答
0
投票

您可以使用Webdriver在id的帮助下单击,直到元素将能够获得点击。

WebDriverWait wait = new WebDriverWait(driver, 50);

wait.until(ExpectedConditions.elementToBeClickable(By.id("button-body")));
© www.soinside.com 2019 - 2024. All rights reserved.