gpt4 book ai didi

java - 在 xml View 中使用 Selenium 1.82 By.xpath 会出现 NoSuchElementException

转载 作者:太空宇宙 更新时间:2023-11-04 10:29:32 26 4
gpt4 key购买 nike

我使用了带有xml View 和java项目的sapui5,使用Selenium 1.82进行自动化测试。当我使用 By.xpath 时,发生 NoSuchElementException 。我尝试过 By.xpath(“//*[text()[contains(., ‘”+ parent +”’)]]” 和 By.xpath(“//*contains(@text, ‘”+ parent +”’))”) ,发生了同样的异常。我应该怎么做?如果有人提供建议,我们将不胜感激。

Relation.view.xml

<Select id=”relationSelect” selectedKey=”{Page>relation}”>
<item>
<core:Item key=”1” text=”請選擇”/>
<core:Item key=”2” text=”父母”/>
<core:Item key=”3” text=”配偶”/>
</item>
</Select>

测试脚本(驱动程序已实例化)

WebDriverWait wait = new WebDriverWait(driver, 30);
WebElement e = driver.findElement(By.xpath(“//*[text()=’”+ “父母” +”’]”);
wait.until(ExpectedConditions.elememtToBeClickable(e));
e.click();

我也尝试了By.id(“relationSelect”),得到了同样的异常。代码By.xpath("//[*text()='"+ " parent "+"']");今年4月17日至3月26日期间工作。那天(4 月 17 日)之后,当我在 5 月 2 日重新启动运行自动测试时,它失败了。

最佳答案

试试这个代码:

WebDriverWait wait = new WebDriverWait(driver, 30);
WebElement e = wait.until(ExpectedConditions.elememtToBeClickable(driver.findElement(By.xpath(“//*[contains(text(),’”+ “父母” +”’]”)))));
e.click();

关于java - 在 xml View 中使用 Selenium 1.82 By.xpath 会出现 NoSuchElementException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50173903/

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