0

I keep getting an error for my selenium "Unable to locate element:". Its python so if someone could help me that would be awesome. Ive already tried giving it time like a lot of time not just sleeping for 3 that dosnt seem to be the issue .error right here woopass=driver.find_element_by_id("turbo-checkout-pyo-button")

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver =webdriver.Chrome(PATH)
#start

driver.get("https://www.amazon.com/ap/signin?openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.com%2Fref%3Dnav_signin&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=usflex&openid.mode=checkid_setup&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&")


username=driver.find_element_by_name("email")
username.send_keys("*********")
continuebutton=driver.find_element_by_id("continue")
continuebutton.click()
passwordenter=driver.find_element_by_name("password")
passwordenter.send_keys("*******")
signInSubmit=driver.find_element_by_id("signInSubmit")
signInSubmit.click()
#garbage

time.sleep(1)
driver.get("https://www.amazon.com/Monster-Energy-Sugar-Drink-Watermelon/dp/B08JNWFT52/ref=sr_1_2?dchild=1&keywords=watermelon&qid=1614867030&sr=8-2")

trube=False
while not trube:
    try:
        stuff=driver.find_element_by_id("outOfStock")
        print("working")
        time.sleep(1)
        driver.refresh()
        
        
    except:
        pressingbutton=WebDriverWait(driver,.0000000000000000000000000000000001).until(EC.presence_of_element_located((By.ID,"buy-now-button")))
        
        pressingbutton.click()


            
        
        time.sleep(3)
        #error right here woopass=driver.find_element_by_id("turbo-checkout-pyo-button")
        #Ive already tried giving it time like a lot of time not just sleeping for 3
        #I dont know why I get this error Unable to locate element:
        #PROBLEM CODE
        #VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
        woopass=driver.find_element_by_id("turbo-checkout-pyo-button")
        #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        
        woopass.click()
    
        trube=True
        
        



        

        
print ("Done")
driver.quit()

this is where im pulling it from

<input id="turbo-checkout-pyo-button" data-testid="" class="a-button-input" type="submit" value="Place your order" aria-labelledby="turbo-checkout-place-order-button-announce"> ```

3
  • is it in an iframe? Commented Mar 4, 2021 at 20:20
  • whats an iframe? How would I tell if it was one? Commented Mar 4, 2021 at 20:22
  • please add screen shot of what element is it , i cant find any element like that Commented Mar 5, 2021 at 0:52

1 Answer 1

1

driver.switch_to.frame(driver.find_element_by_id("turbo-checkout-iframe")) It was an iframe im sorry thanks to all those who contributed. @DMart

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.