Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

205
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda