Selenium Webdriver – click on hidden elements

Try this: 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>”); Be aware, by changing the visibility of an input field you … Read more

How to type some text in hidden field in Selenium WebDriver using Java

First of all you have to change the value of type attribute as text from hidden. The following code using javascript would work for that: jse.executeScript(“document.getElementsByName(‘body’)[0].setAttribute(‘type’, ‘text’);”); Now, you are able to type on that text by using WebDriver. So, the overall code for typing in a hidden field with WebDriver using Java and Javascript … Read more

How to read text from hidden element with Selenium WebDriver?

Might be useful as well: In some cases, one may find it useful to get the hidden text, which can be retrieved from element’s textContent, innerText or innerHTML attribute, by calling element.attribute(‘attributeName’). element.getAttribute(“textContent”) worked for me. See more details there -> http://yizeng.me/2014/04/08/get-text-from-hidden-elements-using-selenium-webdriver/