Can't Locate Element On Microsoft Sign In Page
I'm currently trying to locate Microsoft Sign In page's email input box by using xpath (others as well) but after many tries I still can't locate the correct element for it. After
Solution 1:
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 either of the following Locator Strategies:
Using
XPATH:WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH, "//iframe[@class='landing-signin-hrd' and @id='hrdIframe']"))) login = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@class='form-control' and @placeholder='Email, phone, or Skype']"))) login.send_keys("StrangerSphinx") login.send_keys(Keys.RETURN)Using
CSS_SELECTOR:WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR, "iframe.landing-signin-hrd#hrdIframe"))) login = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input.form-control[placeholder='Email, phone, or Skype']"))) login.send_keys("StrangerSphinx") login.send_keys(Keys.RETURN)
Reference
You can find a relevant detailed discussion in Ways to deal with #document under iframe
Post a Comment for "Can't Locate Element On Microsoft Sign In Page"