How to read text from hidden element with Selenium WebDriver?

后端 未结 8 2189
难免孤独
难免孤独 2020-11-27 15:38

I\'m trying to read the example String 1000 out of a hidden

like this:

8条回答
  •  甜味超标
    2020-11-27 15:43

    I came across the same problem of reading invisible elements but I wanted back a WebElement object to do further parsing (not just its text).

    This bit of code fulfilled my requirement.

    (WebElement) ((JavascriptExecutor) driver).executeScript(
        "arguments[0].style[\"display\"] = \"block\";"+
        "arguments[0].style[\"visibility\"] = \"visible\";"+
        "return arguments[0];", 
    element);
    

提交回复
热议问题