Reputation: 1
I want to click on an element as follows:
//select[@name='instructionSelection']
But its not clicking with Selenium on IE 11.
HTML:
Upvotes: 0
Views: 141
Reputation: 193088
As the the desired element is within an <iframe>
so to invoke click()
on the element you have to:
You can use the following Locator Strategies::
Using CSS_SELECTOR
:
WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[name='invoiceDeatils'][src*='invoiceDeatils']")))
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "select[name='instructionSelection']"))).click()
Using XPATH
:
WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[@name='invoiceDeatils' and contains(@src, 'invoiceDeatils')]")))
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//select[@name='instructionSelection']"))).click()
Note : You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
You can find a relevant discussion in:
Upvotes: 0
Reputation: 14135
You have to switch to iframe using name=InvoiceDeatils
before interacting with the element.
Not sure which language you are using. Providing the snippet in python below.
driver.switch_to.frame(driver.find_element_by_name('InvoiceDeatils'))
# now click on the element
driver.find_element_by_xpath("//select[@name='instructionSelection']").click()
Upvotes: 1