Javascript Selenium Java CSS选择器错误?
那代码工作得很好!在span标记中找到我的唯一一个按钮,然后单击Javascript Selenium Java CSS选择器错误?,javascript,html,css,selenium,Javascript,Html,Css,Selenium,那代码工作得很好!在span标记中找到我的唯一一个按钮,然后单击 driver.findElement(By.cssSelector("span[id$=somePagesCollection] a")).click(); 然后,单击按钮后,出现输入字段 driver.findElement(By.cssSelector("span[id$=somePagesCollection] input[id$=somePagesCollection_0_url]")).sendKeys("some")
driver.findElement(By.cssSelector("span[id$=somePagesCollection] a")).click();
然后,单击按钮后,出现输入字段
driver.findElement(By.cssSelector("span[id$=somePagesCollection] input[id$=somePagesCollection_0_url]")).sendKeys("some");
我有什么
org.openqa.selenium.NoSuchElementException:无法定位元素:
{“方法”:“css选择器”,“选择器”:“span[id$=somePagesCollection]
输入[id$=somePagesCollection\u 0\u url]“}命令持续时间或超时:16
毫秒
查看该元素的外部html。我做错了什么
<input id="s567bb2e58337a_somePagesCollection_0_url" name="s567bb2e58337a[somePagesCollection][0][url]" required="required" class=" form-control" type="url">
浏览器控制台中的另一个示例运行良好,但在selenium中不起作用
$('span[id$=somePagesCollection] tr:nth-child(2) td:nth-child(2) input').hide()
尝试在发送数据之前等待元素
WebDriverWait wait=new WebDriverWait(driver,30);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("span[id$=somePagesCollection] input[id$=somePagesCollection_0_url]"))).sendKeys("some");
WebDriverWait wait=new WebDriverWait(driver,30);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("span[id$=somePagesCollection] input[id$=somePagesCollection_0_url]"))).sendKeys("some");