Selenium Webdriver - click on hidden elements

前端 未结 5 1357
自闭症患者
自闭症患者 2020-11-27 16:58

I am trying to automate upload file functionality in Google Drive.

The element used to pass parameters is hidden with height - 0px.

None of the user actions

5条回答
  •  暖寄归人
    2020-11-27 17:40

    Try this:

    WebElement elem = yourWebDriverInstance.findElement(
       By.cssSelector(".uploadmenu > input"));
    String js = 
      "arguments[0].style.height='auto'; arguments[0].style.visibility='visible';";
    ((JavascriptExecutor) yourWebDriverInstance).executeScript(js, elem);
    

    Here I have replaced XPath by CSS Selector. Let me know Is the above scripting is working or not.

提交回复
热议问题