0

I wrote a code to automatise the inscriptions for a sneakers raffle, but the main problem I have is that webdriver is unable to find the elements, which I find really odd. I'll put the link to the website and the sample of my code that is relevant. Maybe this is due to an anti-bot, but that seems unlikely since the site seems to lack of security. This is the website:

https://r1.dotmailer-surveys.com/2a5ece38e398a86d1d2ieba093b44fa8fd3a-610c7264a82913e254v5f2457bdb04a5a308

I try down here to find the element by a short xpath, long xpath and ID but neither one of them work.

driver = webdriver.Chrome(executable_path='../drivers/chromedriver', chrome_options=options)

driver.get('https://r1.dotmailer-surveys.com/2a5ece38e398a86d1d2ieba093b44fa8fd3a-610c7264a82913e254v5f2457bdb04a5a308')

            time.sleep(delay)

            search = driver.find_element_by_id('textbox-3').send_keys(Prenom)

            time.sleep(delay)

            search = driver.find_element_by_xpath('//*[@id="textbox-4"]').send_keys(Nom)

            time.sleep(delay)

            search = driver.find_element_by_xpath('/html/body/form/div[2]/div/div/div/div[2]/div/div[1]/div/div[10]/input').send_keys(Mail)

            time.sleep(delay) 

It always returns me an error message even when I put a big delay or webdriverwait. I'm super confused, if someone could help me i would be really thankful. This is the error message I get:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="textbox-3"]"}

You can go check out the website if you like to verify that this is indeed the good IDs and Xpaths.

I'm really clueless about what's going on. I don't know if it's relevant but I use python.

Thanks for your help!

Inakivgl
  • 7
  • 2
  • 1
    Seems like the same issue as: https://stackoverflow.com/questions/24369249/python-with-selenium-unable-to-locate-element-which-really-exist – AviatingFotographer Dec 17 '20 at 17:40
  • Maybe that `time.sleep` is not enough for element to appear. Or maybe the element is inside of an `iframe`. Also, I would recommend to use explicit wait, instead of `time.sleep`. https://www.selenium.dev/documentation/en/webdriver/waits/#explicit-wait – KunLun Dec 17 '20 at 17:55

1 Answers1

0

Yep, it is in an iFrame. You will need to switch focus to the iFrame to find the text elements and interact with them.

BCR
  • 46
  • 2