我正在寻找硒中的一些元素,但我有问题。没有像ID这样的正常元素。
问题1->应该单击继续按钮
<a _ngcontent-c3="" routerlink="cms" href="/cms">Continue</a>问题2->应单击以添加按钮
<button _ngcontent-c11="" aria-label="Add user" class="action-btn add" type="button"> 我尝试通过PartialLinkText使用烦躁元素,我试图创建自己的CSS选择器/xPath,但是测试用例总是失败.
问题1的一个不成功的解决办法是:
WebElement continueButton = driver.findElement(By.partialLinkText("Continue"));
continueButton.click();有什么建议吗?谢谢。
发布于 2017-10-14 16:08:05
您可以逐类找到按钮,我希望使用这个xpath,您的问题就在这里,您可能的xpath是//a[@routerlink='cms'][text()='Continue']和//button[@aria-label='Add user']/i']。
(新的.until(ExpectedConditions.elementToBeClickable(By.xpath("//a@routerlink='cms'")));(WebDriverWait,30)) WebDriverWait Continue.click();
WebElement adduser = (new WebDriverWait(driver, 30))
.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@aria-label='Add user']/i")));
adduser.click();https://stackoverflow.com/questions/46746244
复制相似问题