Selenium GeckoDriver没有在Firefox浏览器中输入Firstname字段的值
Firefox驱动程序没有为Selenium GeckoDriver没有在Firefox浏览器中输入Firstname字段的值,selenium,selenium-webdriver,xpath,css-selectors,geckodriver,Selenium,Selenium Webdriver,Xpath,Css Selectors,Geckodriver,Firefox驱动程序没有为Firstname字段输入值。 我正在尝试以下方法: driver.findElement(By.xpath(//*[@id=\JNHGYHG\"]")).sendsKeys("Hello"); 有人能帮我吗?试试这个,看看有什么不同 driver.findElement(By.xpath("//*[@id='JNHGYHG']")).sendKeys("Hello"); 正如您在代码试用中提到的,在您使用的代码中有一个错误 解决方案 您可以使用以下任一解决方案:
Firstname
字段输入值。
我正在尝试以下方法:
driver.findElement(By.xpath(//*[@id=\JNHGYHG\"]")).sendsKeys("Hello");
有人能帮我吗?试试这个,看看有什么不同
driver.findElement(By.xpath("//*[@id='JNHGYHG']")).sendKeys("Hello");
正如您在代码试用中提到的,在您使用的代码中有一个错误 解决方案 您可以使用以下任一解决方案:
- 使用id属性:
driver.findElement(By.id("JNHGYHG")).sendKeys("Hello");
- 使用cssSelector:
- 使用xpath(选项A):
- 使用xpath(选项B):
sendKeys
。您有一个小错误。您当前提供的代码无法生成。请修复它并更新问题。另外,当您可以使用By.ID(“JNHGYHG”)
时,为什么只使用XPath作为ID?我尝试了上述所有选项并获得了这条消息。org.openqa.selenium.WebDriverException:无法将数据转换为对象每当我在Firefox中运行测试用例时,我都会收到cookies弹出窗口我想删除它我该怎么做?我们使用cookies来改善您的体验。为了遵守新的电子隐私指令,我们需要请求您同意设置cookies。了解更多。你能在这里共享html吗?由于隐私问题,我无法共享html。这就是为什么我问ho我可以用这种ID运行脚本。因为我收到一条错误消息org.openqa.selenium.NoSuchElementException:找不到元素:#JNHGYHGCorrect您可以只共享受影响的部分html快照。来吧,您可以这样做。driver.findElement(By.ID(“JNHGYHG”)。sendKeys(“Hello”);《睡眠》(2000年);这不是html,我是问你什么时候检查元素,提供元素的html部分,而不是你写的java代码。
driver.findElement(By.cssSelector("#JNHGYHG")).sendKeys("Hello");
driver.findElement(By.xpath("//*[@id='JNHGYHG']")).sendKeys("Hello");
driver.findElement(By.xpath("//*[@id=\"JNHGYHG\"]")).sendKeys("Hello");