Como fazer login com selenium webdriver

Sep 11 2020

Olá, estou tentando fazer login automaticamente com o driver da web nesta página da web: https://www.oddsportal.com/login/

Aqui está o meu script:

#!/usr/bin/python3
# -*- coding: utf­-8 ­-*-

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from concurrent.futures import ThreadPoolExecutor

import pandas as pd

options = Options()
#options.headless = True
options.add_argument("window-size=1400,800")
options.add_argument("--no-sandbox")
options.add_argument("--disable-gpu")
options.add_argument("start-maximized")
options.add_argument("enable-automation")
options.add_argument("--disable-infobars")
options.add_argument("--disable-dev-shm-usage")

driver = webdriver.Chrome(options=options)

driver.get("https://www.oddsportal.com/login/")

driver.find_element_by_id("login-username1").send_keys("ahmedaao")
driver.find_element_by_id("login-password1").send_keys("password")
driver.find_element_by_name("login-submit").click()

Tenho um problema com a última linha de código. A página da web abre e o nome de usuário e a senha são cobrados, mas eu não estou conectado.

Respostas

ahmedaao Sep 12 2020 at 19:06

Eu encontro a solução:

driver.find_element_by_xpath('//button[@type="submit"]').click()