Issue
I am trying to access the ESPN NBA Fantasy to automatize the consult of league standing.
I cannot go throug the email step because I cant find the element to send my email.
This is what I got already:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver.implicitly_wait(5)
driver.get('https://fantasy.espn.com/basketball/league/standings? leagueId=1940892466&statView=official')
driver.find_element("id", "onetrust-accept-btn-handler").click()
driver.find_element(By.XPATH, "//*[@id='InputIdentityFlowValue']").send_keys('[email protected]')
But this error message occurs:
NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='InputIdentityFlowValue']"}
(Session info: chrome=118.0.5993.118)
Stacktrace:
GetHandleVerifier [0x00BC4DE3+43907]
(No symbol) [0x00B50741]
(No symbol) [0x00A433ED]
(No symbol) [0x00A76760]
(No symbol) [0x00A76C2B]
(No symbol) [0x00AA6F62]
(No symbol) [0x00A92BA4]
(No symbol) [0x00AA55CA]
(No symbol) [0x00A92956]
(No symbol) [0x00A6E17E]
(No symbol) [0x00A6F32D]
GetHandleVerifier [0x00E75AF9+2865305]
GetHandleVerifier [0x00EBE78B+3163435]
GetHandleVerifier [0x00EB8441+3138017]
GetHandleVerifier [0x00C4E0F0+605840]
(No symbol) [0x00B5A64C]
(No symbol) [0x00B56638]
(No symbol) [0x00B5675F]
(No symbol) [0x00B48DB7]
BaseThreadInitThunk [0x760A7BA9+25]
RtlInitializeExceptionChain [0x7744BD2B+107]
RtlClearBits [0x7744BCAF+191]
Solution
There is an IFRAME
which is wrapping the desired element. You need to first switch into the IFRAME
and then perform any actions.
Check the code below:
driver.implicitly_wait(5)
driver.get('https://fantasy.espn.com/basketball/league/standings? leagueId=1940892466&statView=official')
driver.find_element("id", "onetrust-accept-btn-handler").click()
driver.switch_to.frame("oneid-iframe")
driver.find_element(By.XPATH, "//*[@id='InputIdentityFlowValue']").send_keys('[email protected]')
Below code should be used to come out of IFRAME once you have performed actions
driver.switch_to.default_content()
Suggestion: Read about IFRAMES from the official documentation here Working with IFrames and frames
Answered By - Shawn
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.