2

I am using Firefox geckodriver. I want to load a page and click on "I want it too button" which has id="J_cutBtn"

but I get error that

Element <div id="J_cutBtn" class="cut-btn"> is not reachable by keyboard

I tried to add the scroll down the page and also added Wait Until Object is clickable.

here is the Code:

from selenium import webdriver

from selenium.webdriver.common.keys import Keys


from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By


firefox_profile = webdriver.FirefoxProfile()
firefox_profile.set_preference("browser.privatebrowsing.autostart", True)

path="C:/Users/Gupta Niwas/Downloads/Programming/College Projects/SEM 4/PBL SEM 4/geckodriver-v0.20.0-win64/geckodriver.exe"

browser = webdriver.Firefox(firefox_profile=firefox_profile,executable_path=path)



browser.get("https://mobile.mi.com/in/24hrMadness/task/?activityId=15&taskId=1026420&goodsId=4181200024&mi_channel=Social&mi_source=copyurl&mi_campaign=24hrMadness")
print(browser.title)
browser.execute_script("window.scrollTo(0, 900)") 
browser.implicitly_wait(1000)
 WebDriverWait(browser,10).until(EC.element_to_be_clickable((By.ID,"J_cutBtn")))
drop_btn=browser.find_element_by_id("J_cutBtn")
drop_btn.send_keys(Keys.RETURN)

1 Answer 1

1

Use click():

drop_btn.click()

The button cannot be used with .send_keys(Keys.RETURN)

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.