Cómo iniciar sesión con selenium webdriver

Sep 11 2020

Hola, estoy intentando iniciar sesión automáticamente con webdriver en esta página web: https://www.oddsportal.com/login/

Aquí está mi guión:

#!/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()

Tengo un problema con la última línea de código. La página web se abre, luego se cobran el nombre de usuario y la contraseña, pero luego no he iniciado sesión.

Respuestas

ahmedaao Sep 12 2020 at 19:06

Encuentro la solución:

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