I’m trying to locate an element on a page. If I do Inspect Element, I can see the HTML code and the element id = username
, but when I view page source, there is only Javascript
code. Any idea on how to see the HTML page instead?
This is the page: https://pje.tjmg.jus.br/pje/login.seam
That is my code:
username_input = WebDriverWait(driver, 60).until(EC.element_to_be_clickable((By.ID, 'username')))
username_input.clear()
username_input.send_keys(cpf)
3
Answers
It’s inside an iframe.
Try the page in the iframe instead: https://pje.tjmg.jus.br/pje/authenticateSSO.seam
Desired element(
@id=username
) is wrapped within aniframe
. You first need to switch into theiframe
and then perform any action.Refer the below working code:
Result:
Switching back to default content: To come out of
iframe
use the code below.The Username field is within an
<iframe>
so you have to:Induce WebDriverWait for the desired frame to be available and switch to it.
Induce WebDriverWait for the desired element to be clickable.
You can use either of the following locator strategies:
Using CSS_SELECTOR:
Using XPATH:
Note : You have to add the following imports :
Browser Snapshot:
Reference
You can find a couple of relevant discussions in: