Skip to content Skip to sidebar Skip to footer

Make Webelement Visible Via Selenium With Python With Javascript

I'm trying to upload a png via selenium. My Problem is, that the Input I need to use, is invisible to selenium, but not to the user. In the FAQ of Selenium they told me to use the

Solution 1:

There is an execute_script() method on the driver instance, arguments are passed to it in a similar to C#'s JavascriptExecutor:

icon = element.find_element_by_css_selector("input")
driver.execute_script("arguments[0].style.visibility = 'visible'; arguments[0].style.height = '1px'; arguments[0].style.width = '1px'; arguments[0].style.opacity = 1", icon)

Solution 2:

In my case, the invisibility of the element was due to having display:none; in the style. So the solution was:

driver.execute_script("arguments[0].style.display = 'block';", element)

Post a Comment for "Make Webelement Visible Via Selenium With Python With Javascript"