gpt4 book ai didi

xpath - Selenium WebDriver findElement(By.xpath()) 对我不起作用

转载 作者:行者123 更新时间:2023-12-03 15:24:32 24 4
gpt4 key购买 nike

我已经阅读了 xpath 教程并检查了许多其他帖子,因此我不确定我错过了什么。我只是想通过 xpath 找到以下元素:

<input class="t-TextBox" type="email" test-id="test-username"/>

我尝试了很多东西,例如:
element = findElement(By.xpath("//[@test-id='test-username']"));

错误是 Expression is not a legal expression .

我在 MacBook 上使用 Firefox

任何建议将不胜感激。

最佳答案

element = findElement(By.xpath("//*[@test-id='test-username']");
element = findElement(By.xpath("//input[@test-id='test-username']");

(*) - 任何标记名

关于xpath - Selenium WebDriver findElement(By.xpath()) 对我不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16952514/

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