gpt4 book ai didi

java - Webelement 查找问题

转载 作者:行者123 更新时间:2023-11-30 01:49:30 25 4
gpt4 key购买 nike

Webelement 在下面提到的案例中发现问题

在网页上https://pastebin.com/需要从“粘贴有效期:”下拉列表中选择选项“10 分钟”

以下是采取的步骤:

//Identification the Never option and clicking it the dropdown to show up
//This part of the code works
WebElement pasteExpiration = driver.findElement(By.xpath("//*[@class='form_frame_left']//*[@title = 'Never']"));
pasteExpiration.click();

//Selecting the'10 Minute' option, this code is not identified by the WebDriver
WebElement pasteExpiration10Minutes = driver.findElement(By.cssSelector("#select2-paste_expire_date-q4-container"));

WebDriver 没有看到“10 分钟”选项字段,我们尝试编写自己的 xpath,但没有任何效果。

最佳答案

请尝试以下几行:

driver.findElement(By.xpath("//span[starts-with(@id,'select2-paste_expire_date')]")).click();
driver.findElement(By.xpath("//li[text()='10 Minutes']")).click();

这对我有用。我检查过chrome浏览器。

关于java - Webelement 查找问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56558372/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com