1

Im trying to login in a page (url) and selenium its not even been able to send input keys. I tried:

driver.find_element(By.XPATH,'//input[@formcontrolname="ag"]')

I also tried to pick up by ID but its generated dynamically.

Even though the element its there in the page selenium cant find it. I also tried manually using DevTools and no success, something seems to be blocking me from using scripts and I cant find it.

Element Im trying to send input:

<input mask="0000" type="text" formcontrolname="ag" style="background-color: #f0f0f0; border: 0px; width: 4rem; font-size: 14px;" class="ng-untouched ng-pristine ng-invalid dss-form-field__input" id="nhqkx-181131441b-11333-14a03-19d73-1142d11a351af5a">

Edit: There isnt a iframe in devtools console, but I saw this strange tag which I dont know if its blocking me from walking with xpath

<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-THV465P"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
Kabllez
  • 67
  • 6

2 Answers2

1

Try this:

 wait = WebDriverWait(driver, 3)
 element = wait.until(
                EC.visibility_of_element_located((By.XPATH, "//input[@id='nhqkx-181131441b-11333-14a03-19d73-1142d11a351af5a']"))
 )
 element.send_keys("please replace your content")
HappySid
  • 29
  • 7
  • The ID "nhqkx-181131441b-11333-14a03-19d73-1142d11a351af5a" changes every time you access the website and even if you try use this in devtools manually it wont work for an unkown reason – Kabllez Aug 22 '23 at 17:58
  • Avoid code only answer and provide an explanation. – Itération 122442 Aug 24 '23 at 14:00
0

the answer is https://stackoverflow.com/a/76598852/17601704

you should go to the iframe firstly before you send_keys to input

view the document https://www.selenium.dev/documentation/webdriver/interactions/frames/

driver.switch_to.frame("passport_iframe")

or

# switching to second iframe based on index
iframe = driver.find_elements(By.TAG_NAME,'iframe')[1]

# switch to selected iframe
driver.switch_to.frame(iframe)

after you finish send_keys and want to leave the iframe, you should using this line

# switch back to default content
driver.switch_to.default_content()
Jiu_Zou
  • 463
  • 1
  • 4