Remove readonly attributes in Selenium WebDriver

前端 未结 3 1607
北恋
北恋 2021-01-13 15:21

I need to edit some readonly fields with Selenium WebDriver in Java. As Selenium won\'t let me even find this fields I searched for solutions and found that the

3条回答
  •  悲哀的现实
    2021-01-13 15:48

    I was not able to find the issue with your code. But in the meantime use the code given below.

    List inputs = driver.findElements(By.tagName("input"));
    
    for (WebElement input : inputs) {
        ((JavascriptExecutor) driver).executeScript(
                    "arguments[0].removeAttribute('readonly','readonly')",input);
    }
    

    Let me know if this helps you.

提交回复
热议问题