Answer the question
In order to leave comments, you need to log in
Can't find text input element with Selenium, what's the reason?
I am writing a code to insert a card number into the input field, as I understand it, there is protection. How do I get around it, I attach a photo of the page code:
And a screenshot of what Selenium sees
Python code:
chrome_options = webdriver.ChromeOptions()
chrome_options.binary_location = os.environ.get("GOOGLE_CHROME_BIN")
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("--no-sandbox")
driver = webdriver.Chrome(executable_path='chromedriver.exe', chrome_options=chrome_options)
driver.get("https://www.amediateka.ru/signin")
driver.maximize_window()
driver.find_element_by_xpath("//input[@class='registration__form-input'][@type='email']").send_keys("[email protected]")
driver.find_element_by_xpath("//input[@class='registration__form-input'][@type='password']").send_keys("12211221Ma1")
driver.find_element_by_xpath("//button[@class='registration__form-button active']").click()
await asyncio.sleep(2)
driver.find_element_by_xpath("//div[@class='Menu_menu__burger__29MKo']").click()
await asyncio.sleep(0.1)
driver.find_element_by_xpath("//a[@class='Account_account__link__3ytrA'][text()='Покупки']").click()
await asyncio.sleep(4)
driver.find_element_by_xpath("//div[@class='settings-button settings-button_yellow-action']").click()
await asyncio.sleep(0.5)
driver.find_element_by_xpath("//button[@class='btn btn_block btn btn_primary']").click()
await asyncio.sleep(10)
driver.save_screenshot("screenshot.png")
try:
driver.find_element_by_xpath("//input[@id='cardNumber'][@class='payment__input payment__card-field']").send_keys(card)
except:
driver.find_element_by_css_selector('input#cardNumber.payment__input.payment__card-field')
await asyncio.sleep(1)
driver.save_screenshot("screenshot_2.png")
Answer the question
In order to leave comments, you need to log in
And click on the element before entering data:
to_card = driver.find_element_by_xpath("//input[@id='cardNumber'][@class='payment__input payment__card-field']")
to_card.click()
to_card.send_keys(card)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question