3

currently blocked with this tricky scenario

please refer to attached screen shot for code

I'm not able to change value of header.

<div class="tb-title-container unedited"> 
 <h1 class="tb-headline-inner">Untitled List</h1> 
 <input type="text" maxlength="255" class="tb-title-input chromeless"> <label class="tb-list-options">
 </label> </div>

enter image description here

code generated by Selenium IDE

I tried javascript approach as well to set value of header field , but it's not getting changed. As header name change takes place only with keyboard enter key press.

driver.findElement(By.cssSelector("label.tb-list-options > svg")).click(); driver.findElement(By.cssSelector("li.rename.blue")).click(); driver.findElement(By.cssSelector("input.tb-title-input.chromeless")).clear(); driver.findElement(By.cssSelector("input.tb-title-input.chromeless")).sendKeys("vikram");

java code

WebElement inputField  = getDriver().findElement( By.xpath("//div[@class='tb-title-container']/h1[@class='tb-headline-inner']") );

 ( (JavascriptExecutor)getDriver() ).executeScript("arguments[0].value='VIKRAM'", inputField);
8
  • so you need to press ENTER after typing to change that field? Then you're missing something like inputField.sendKeys(Keys.ENTER); I am confused by what the problem is, are you not able to locate that, type a new value or press enter once you have your new input. Commented Apr 1, 2016 at 11:35
  • @ingrid.e sendKeys on this field throws error element not visible. I'm not able to mimic user actions on this input field either with normal selenium methods or with javascript as well. Commented Apr 1, 2016 at 13:27
  • what is the type of that field? can you not locate it using classname instead? Commented Apr 1, 2016 at 13:35
  • as per solution from Kith below , I could locate and set value programmatically but new valud doesn't reflect in UI. It only updates in UI , once enter key press is done ( during manual interaction ) , how to update value of this field and then do enter key press ? Commented Apr 1, 2016 at 13:40
  • what is the type of that element? that is important Commented Apr 1, 2016 at 13:42

1 Answer 1

0

Have you tried

((JavascriptExecutor)driver).executeScript("document.getElementsByClassName('tb-title-container').innerHTML='vikram'");
Sign up to request clarification or add additional context in comments.

4 Comments

Hi Kith, this didn't work as well. I think the step missing is after assigning value , need to do enter key press to confirm the action. Also please put vikram in single quotes in above line ; as above one throws error
Just found a relative issue. Hope it will help.stackoverflow.com/questions/21695714/…
sorry I didn't understand the solution from the link you posted. My understanding with javascript is very limited and still learning tricks in it. can you please paste the code here ? And below is what I tried WebElement inputField = getDriver().findElement( By.xpath("//div[contains(@class,'tb-title-container')]/h1[@class='tb-headline-inner']") ); ((JavascriptExecutor)getDriver()).executeScript("document.getElementsByClassName('tb-title-container').value='vikram'"); ((JavascriptExecutor)getDriver()).executeScript("arguments[0].click();", inputField);
sorry it didn't work. I tried the javascript part in FF console , it does pass in console only but doesn't reflect change in UI. I think after this method , it needs enter action through javascript ?

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.