1

I am using Javascript executor to remove readonly attribute but it is giving an error. Cannot read property 'removeAttribute' of null.

I have seen different posts where people confirm that after removing AdBlock from Chrome it worked. I don't know what is AdBlock and how to remove it from Chrome Binary at runtime, so I tried Firefox (Gecko Driver) but it is also throwing the same error.

Code:

driver.get("http://jsfiddle.net/343Rb/"); runJS().executeScript("document.getElementById('myInput').removeAttribute('readonly')"); 

Browsers I tried: Chrome Binary latest, Firefox (GeckoDriver latest) on Windows 7

Links I went through:

  1. TypeError: Cannot read property "removeAttribute" of null
  2. Cannot read property 'removeAttribute' of null: Cant find source of it
  3. Cannot read property *0* of null

Few posts above are purely JS based so I believe is the reason they are not replying to me.

I am using Selenium 3.0, Windows 7, Firefox, Chrome, Java, Testng

1 Answer 1

0

The problem is that the element you want is inside an <iframe>. You need to switch to it before querying for your element:

driver.switchTo().frame('result'); 

Or:

driver.switchTo().frame(driver.findElement(By.name('result'))); 
Sign up to request clarification or add additional context in comments.

1 Comment

You are right, I dont know why I didnt think of it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.