Saya mencoba memecahkan proyek latihan dari otomatisasi hal-hal yang membosankan dengan buku Python3 di mana saya diminta untuk membangun program dengan Selenium. Di mana ia menemukan input email dan kata sandi dan menetapkannya ke ...

0
seprico 6 April 2021, 00:00

1 menjawab

Jawaban Terbaik

Saya baru saja menguji kode ini dan berfungsi. Tolong beri tahu saya jika Anda memiliki masalah.

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


firefox_options = Options()
firefox_options.add_argument("--test-type")
firefox_options.add_argument('--ignore-certificate-errors')
firefox_options.add_argument("--disable-infobars")
firefox_options.add_argument("--disable-extensions")
firefox_options.add_argument("--disable-popup-blocking")

driver = webdriver.Firefox(executable_path='/usr/local/bin/geckodriver', options=firefox_options)

driver.get('https://login.live.com/')

username_box = WebDriverWait(driver, 60).until(EC.presence_of_element_located((By.CSS_SELECTOR, '.input.text-box')))
username_box.send_keys('test@outlook.com')

driver.implicitly_wait(10)

next_button = driver.find_element_by_css_selector('.button.primary')
next_button.click()

password_box = WebDriverWait(driver, 60).until(EC.presence_of_element_located((By.CSS_SELECTOR, '.input.text-box')))
password_box.send_keys('somepassword')

driver.implicitly_wait(10)

submit_button = driver.find_element_by_css_selector('.button.primary')
submit_button.click()
0
Life is complex 5 April 2021, 21:16