I am trying to login in https://www.ecobolsa.com/index.html with Selenium in python3, but the send_keys functions gets me the message:
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
(Session info: headless chrome=78.0.3904.97)
The code is:
from selenium.webdriver.chrome.options import Options
from selenium import webdriver
options = Options()
options.add_argument('--headless')
options.add_argument('--disable-gpu')
options.add_argument("start-maximized")
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
email = '[email protected]'
password = 'fakepass3'
driver = webdriver.Chrome('chromedriver', options=options)
driver.get('https://www.ecobolsa.com/index.html')
driver.find_element_by_id("userNameTextBox").send_keys(email)
driver.find_element_by_id("password_login").send_keys(password)
I have tried other solutions but none of them have been successful. I need help.
You need to do a lot of things to get this work.
Need to set windows-size since you are dealing with headless mode.By passing the arguments.
options.add_argument("window-size=1920x1080")
-Need to click ACEPTO button and then click on login link.
-Induce WebDriverWait And element_to_be_clickable()
Here is the code.
from selenium.webdriver.chrome.options import Options
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
options = Options()
options.add_argument('--headless')
options.add_argument('--disable-gpu')
options.add_argument("start-maximized")
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
options.add_argument("window-size=1920x1080")
email = '[email protected]'
password = 'fakepass3'
driver = webdriver.Chrome('chromedriver', options=options)
driver.get('https://www.ecobolsa.com/index.html')
WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,"//button[normalize-space()='ACEPTO']"))).click()
loginlink=WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,"//li[@class='login']/a")))
ActionChains(driver).move_to_element(loginlink).click(loginlink).perform()
WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.ID,"userNameTextBox"))).send_keys(email)
WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.ID,"password_login"))).send_keys(password)
print('pass')
To login in within the website https://www.ecobolsa.com/index.html using Selenium you need to:
Induce WebDriverWait for:
ACEPTO to be clickable.Code Block:
options = webdriver.ChromeOptions()
options.add_argument("window-size=1920x1080")
options.add_argument("--headless")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=options, executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
driver.get("https://www.ecobolsa.com/index.html")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.qc-cmp-button[onclick]"))).click()
WebDriverWait(driver, 20).until(EC.invisibility_of_element((By.CSS_SELECTOR, "div.qc-cmp-ui-container.qc-cmp-showing")))
ActionChains(driver).move_to_element(WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "li.login>a")))).click().perform()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input#userNameTextBox"))).send_keys("jatorna")
driver.find_element_by_css_selector("input#password_login").send_keys("jatorna")
driver.save_screenshot('./Screenshots/login.png')
print("Program completed")
driver.quit()
Browser Snapshot:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With