1

That code works very fine! Finds my only one button in that span tag, and clicks.

driver.findElement(By.cssSelector("span[id$=somePagesCollection] a")).click();

Then, after clicking button, appears input field.

driver.findElement(By.cssSelector("span[id$=somePagesCollection] input[id$=somePagesCollection_0_url]")).sendKeys("some");

What i've got?

org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"css selector","selector":"span[id$=somePagesCollection] input[id$=somePagesCollection_0_url]"} Command duration or timeout: 16 milliseconds

Looking into the outer html of that element. What i'm doing wrong?

<input id="s567bb2e58337a_somePagesCollection_0_url" name="s567bb2e58337a[somePagesCollection][0][url]" required="required" class=" form-control" type="url">

Example from browser console.

$('span[id$=somePagesCollection] input[id$=somePagesCollection_0_url]').hide() 

Another example from browser console that works well, but not in selenium.

$('span[id$=somePagesCollection] tr:nth-child(2) td:nth-child(2) input').hide()
0

1 Answer 1

1

Try waiting for the element before sending data

WebDriverWait wait=new WebDriverWait(driver,30);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("span[id$=somePagesCollection] input[id$=somePagesCollection_0_url]"))).sendKeys("some");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.