Seleniumbase TimeoutException only when using chromium from a script

Question:

I have a url login script that was working fine for a few days but then quit, that used the chromium webdriver

driver = webdriver.Chrome('/snap/bin/chromium.chromedriver', options=option)

I can access the URL using Firefox or Chromium without my script (just normal). Or Firefox in a script.
But using Chromium in a script, it clicks the login button and just hangs, that eventually leads to a timeout

selenium.common.exceptions.TimeoutException: Message:

If I open a new tab and try to login without the script but manually, it still hangs. A login is impossible (on my target site) within a launched browser from selenium, only.

#!/usr/bin/python3
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from seleniumbase import BaseCase
import time
import random

user_name = 'user'
password = 'password'
list = [
        ]
minptime = 4
maxptime = 24

list_length = len(list)
print('Array length ', list_length)
class MyMeClass(BaseCase):
        def method_a():
                option = webdriver.ChromeOptions()
                option.add_argument('--disable-notifications')
                option.add_argument("--mute-audio")
                driver = webdriver.Chrome('/snap/bin/chromium.chromedriver', options=option)

                driver.get("https://me.com/")
                print(driver.title)
                element = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.login-btn.btn-shadow#login-fake-btn[data-testid='login-fake-btn']"))).click()
                driver.find_element_by_xpath('/html/body/div[1]/div/div[1]/div/form/input[1]').send_keys(user_name)
                driver.find_element_by_xpath('/html/body/div[1]/div/div[1]/div/form/input[2]').send_keys(password)
                time.sleep(5)
                driver.find_element_by_xpath('/html/body/div[1]/div/div[1]/div/form/button').click() #button click in question
                time.sleep(8)
                driver.get(url)
                print(driver.current_url)
                return driver
driver = MyMeClass.method_a()

button I am accessing

enter image description here

How do I use/unblock the use of this login button in chromium in a script?

Asked By: brad

||

Answers:

Try below code:

with contains

wait = WebDriverWait(driver, 30)
wait.until(EC.element_to_be_clickable((By.XPATH, "//button[contains(text(), 'Log in')]"))).click()

Class Name

wait = WebDriverWait(driver, 30)
wait.until(EC.element_to_be_clickable((By.XPATH, "//button[@class='btn-login btn-shadow']"))).click()

Note : please add below imports to your solution

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

Working Solution:

driver.get(" your url ")
wait = WebDriverWait(driver,30)
element = wait.until(EC.element_to_be_clickable((By.XPATH, "//button[@id='login-fake-btn']")))
print element.text
element.click()

wait = WebDriverWait(driver,30)
element = wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@id='email']"))).send_keys("Test")
wait = WebDriverWait(driver,30)
element = wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@id='password']"))).send_keys("Test")
element1 = wait.until(EC.presence_of_element_located((By.XPATH, "//div[@id='login-overlay']//div//form//button")))
element1.click()

output :

enter image description here

Answered By: SeleniumUser