Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

209
Views
Selenium set value to input field that is not visible

I am trying to set value to an input field via selenium-python but the problem is that it's not visible. So it throws "Element not interactable" error. This is because the input field is part of an "li", that has a role of "tab" and at any point only one "li" can be active (tabindex=0), while the remaining are not visible (tabindex=-1). I am writing an automation script that requires setting the input values in one "tab", and then doing something on the other "tab", but when switching to the other tab, that tab stays active and on the second run the previous tab is no longer active, hence I can't set the value anymore.

I tried deleting all cookies and local and session storage but the change in tab visibility is persistent. Is there any way of doing what I want to do?

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I suggest adding an additional step to your scenario:

Activate the tab for the particular input before setting the value.

From your description, you just have to click on the tab.

So your script might look like this:

from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

def fill_input_filed_a(a_value):
    driver.find_element(tab_for_input_a).click()
    input = WebDriverWait(driver, 10).until(EC.visibility_of_element_located(input_filed_a))
    input.clear()
    input.send_keys(a_value)


def fill_input_filed_b(b_value):
    driver.find_element(tab_for_input_b).click()
    input = WebDriverWait(driver, 10).until(EC.visibility_of_element_located(input_filed_b))
    input.clear()
    input.send_keys(b_value)

# then invoke methods in test
fill_input_filed_a('value1')
fill_input_filed_b('value2')

If you still want to work with hidden field, try

Set value to input field that is not visible

It's possible with JS, but this might not work, since some events might not be fired when you just set the value with java-script.

input_field = driver.find_element(hidden_input_filed)
driver.execute_script("arguments[0].value='"+value+"'", input_field)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!