Changing Display Of Element In Selenium Python Does Not Work

I want to upload a file using Selenium, but first I need to make the input element visible. It looks like that:

<input class="tb_sK" type="file">

I tried changing the style.display using JavaScript with this code:

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

The input now looks like this but is still invisible :

<input class="tb_sK" type="file" style="display: block;">

I'm not very familiar with html, but in the devtools, I saw this : input

There is nothing in and the 'display' is in .tb_sK. So I think I must change this.

How can I do it ?



You could try removing the class attribute:

driver.execute_script("arguments[0].removeAttribute('class')", upload_button)

This way the input won't be affected by the CSS rule you showed in your print and thus won't be invisible anymore.