-1

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 copying the element from the page, this is the element given:

<input type="email" class="form-control" placeholder="Email, phone, or Skype" aria-required="true" spellcheck="false" autocomplete="off" data-bind="
                                    hasFocus: focus,
                                    textInput: email,
                                    attr: {'placeholder': config.text.emailPlaceHolder, 'aria-invalid': !error}">

And this is currently my python code:

login = browser.find_element_by_xpath("//input[@class='form-control']")
login.send_keys(config.username)
login.send_keys(Keys.RETURN)

I had tried multiple times but I still can't get the proper element to proceed. After entering https://forms.office.com/ I had successfully captured the sign in element but stuck at the next page.

Please NOTE that this is similar to this question but is not the same as the page element is quite different. Any help would be greatly appreciated!

1 Answers1

1

Your target element is present in an iframe with id as hrdIframe. So you have to switch to the frame before interacting with the element.

driver.switch_to.frame('hrdIframe')
driver.find_element_by_xpath("//input[@type='email']").send_keys(config.username)

Always make sure you switch back to default frame once you are done with the actions in iframe.

supputuri
  • 13,644
  • 2
  • 21
  • 39