Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ValchanOficial/98835c6862e3527d12f2a99b1d00e115 to your computer and use it in GitHub Desktop.
Save ValchanOficial/98835c6862e3527d12f2a99b1d00e115 to your computer and use it in GitHub Desktop.
selenium-webdriver-click-on-hidden-elements
https://stackoverflow.com/questions/12363038/selenium-webdriver-click-on-hidden-elements
WebElement elem = yourWebDriverInstance.findElement(By.xpath("//*[@class='goog-menu goog-menu-vertical uploadmenu density-tiny']/input"));
String js = "arguments[0].style.height='auto'; arguments[0].style.visibility='visible';";
((JavascriptExecutor) yourWebDriverInstance).executeScript(js, elem);
The above bunch would change the visibility of your file input control. You can then proceed with the usual steps for file upload like:
elem.sendKeys("<LOCAL FILE PATH>");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment