Come accedere con selenium webdriver

Sep 11 2020

Ciao, sto cercando di accedere automaticamente con webdriver a questa pagina web: https://www.oddsportal.com/login/

Ecco il mio 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()

Ho un problema con l'ultima riga di codice. La pagina Web si apre, quindi vengono addebitati nome utente e password, ma non ho effettuato l'accesso.

Risposte

ahmedaao Sep 12 2020 at 19:06

Trovo la soluzione:

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