Skip to content

Instantly share code, notes, and snippets.

@ronivaldo
Created November 5, 2019 01:25
Show Gist options
  • Save ronivaldo/75a73285d151e512b3c181940374d8f3 to your computer and use it in GitHub Desktop.
Save ronivaldo/75a73285d151e512b3c181940374d8f3 to your computer and use it in GitHub Desktop.
selenium
"""
Paginas de Login para Testes:
http://testing-ground.scraping.pro/login
Mais paginas:
http://testing-ground.scraping.pro/
Exemplo simples:
https://selenium.dev/selenium/docs/api/py/
How to Windows:
pip install selenium
get geckodriver for windows/linux
https://github.com/mozilla/geckodriver
on the same folder (or gecko.exe in PATH)
selenium docs:
https://selenium-python.readthedocs.io/locating-elements.html
"""
from selenium import webdriver
#from selenium.webdriver.common.keys import Key
#elem.send_keys('seleniumhq' + Keys.RETURN)
browser = webdriver.Firefox()
browser.get('http://testing-ground.scraping.pro/login')
usr = browser.find_element_by_id('usr')
pwd = browser.find_element_by_id('pwd')
btn_login = browser.find_element_by_xpath("/html/body/div[2]/div[2]/form/input[3]")
usr.send_keys('admin')
pwd.send_keys('12345')
btn_login.click()
#browser.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment