0

I want to click on an element as follows:

//select[@name='instructionSelection']

But its not clicking with Selenium on IE 11.

HTML:

enter image description here

Guy
  • 46,488
  • 10
  • 44
  • 88

2 Answers2

1

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()
supputuri
  • 13,644
  • 2
  • 21
  • 39
0

As the the desired element is within an <iframe> so to invoke click() on the element 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 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
      

Reference

You can find a relevant discussion in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352