1

I am attempting to automate the checkout process of a shopify checkout and selenium can't seem to find the elements necessary to complete the checkout. NOTE: This checkout is not in an iframe and i have done extensive research to make sure that the page is fully loaded, so this is not a duplicate question.

try:
    elem = driver.find_element_by_id('number')
    elem.send_keys('4342923222931029')
except NoSuchElementException:
    assert 0, "can't find input with number id"

Here is what i am trying to access: screenshot of the source code of the checkout code

  • Welcome to SO. Did you try the `#number` css or `//input[@id='number']` in the developer tool (if your are using chrome)? were you able to find the element in chrome browser? – supputuri Apr 28 '19 at 21:49
  • Here is the link with the options to find the elements in the browser (https://stackoverflow.com/questions/55870609/is-there-a-way-to-learn-xpath-without-using-firebug-or-xpath-as-firefox-is-not-s/55870909#55870909). By this way we can figure out whether the issue is with selenium or the identification itself. – supputuri Apr 28 '19 at 21:52
  • @supputuri Thanks so much for your help, so it turns out that this is an iframe issue. I have now found the iframe, however i am now getting the following error when trying to locate the iframe by id: selenium.common.exceptions.NoSuchFrameException: Message: no such frame – user11402161 Apr 28 '19 at 22:17
  • @supputuri here is my code: driver.switch_to.frame('card-fields-number-3nk14ojvg9f00000') – user11402161 Apr 28 '19 at 22:18
  • Check out my answer [here](https://stackoverflow.com/questions/55536851/is-there-a-way-to-search-webelement-on-a-main-window-first-if-not-found-then-s/55537186#comment97778812_55537186) to loop through all the available iframes to find out the element which frame have the element. – supputuri Apr 28 '19 at 22:23
  • @supputuri Here is a post of my exact same issue, it seems they found a fix in java, don't know how to convert to python: https://stackoverflow.com/questions/54576206/selenium-cant-locate-iframe – user11402161 Apr 28 '19 at 22:38

1 Answers1

0

Here is the python code to switch to the correct frame.

ele = driver.find_element_by_xpath("//iframe[contains(id, 'card-fields-number')]")
driver.switch_to.frame(ele);

For Java solution refer here

supputuri
  • 13,644
  • 2
  • 21
  • 39