Reputation: 287
I'm aware that I have to switch to an iframe when I want to click and element inside it. Heres what the start of the iFrame looks like:
<iframe src="about:blank" name="tool_content" id="tool_content" class="tool_launch" allowfullscreen="allowfullscreen" webkitallowfullscreen="true" mozallowfullscreen="true" tabindex="0" title="Tool Content" style="height: 100%; width: 100%;" allow="geolocation *; microphone *; camera *; midi *; encrypted-media *; autoplay *" data-lti-launch="true"></iframe>
I switched to it using driver.switch_to.frame(driver.find_element_by_class_name("tool_launch"))
I then tried clicking a 'Join' button inside the Iframe by using it's exact xpath:
driver.find_element_by_xpath("/html/body/div[1]/div/div/div[2]/div/div/div[3]/div[1]/div[2]/div/div/div/div/div/div/div/div/div/div/table/tbody/tr/td[4]/div/div[1]/a").click()
But it keeps saying it's not present. Why? There are no further iframes inside that one, and this xpath is completely 100% inside the iframe. It can recognise other elements, so why not this one?
<a target="_blank" href="/lti/rich/j/96494344321?oauth_consumer_key=AAPUZMZcQCSN85nnG74vOQ&lti_scid=ee49a632bee823b3046456c29c5eb4064ee1e3790f433af82bebaf2752bde531" class="ant-btn ant-table-span" style=""> Join</a>
Heres what the iframe looks like - I want to click the join button:
It's inside a table.
I'm able to select things like the 'previous meetings' tab, but cannot use the Join or invitation buttons.
The two images just continue on from one another.
I tried using the css selector - same result.
Upvotes: 0
Views: 1093
Reputation: 9969
Try waiting and clicking on the element. Try not to use xpath.
elem=WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a.ant-btn.ant-table-span")))
elem.click()
Import
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
Upvotes: 2