项目介绍:
在这里,我们将研究使用selenium登录GFG的简单方法。 Selenium是一个免费工具,可以跨特殊的浏览器自动进行试用。然后是一个简单的需求ID和密码。
要求 :
- Selenium – Selenium Python简介和安装
设置步骤–
- 首先,使用此链接转到GeeksforGeeks网站。
- 然后通过紧急ctrl + shift + i单击调查元素,或进入浏览器设置并手动单击调查详细信息。
- 然后在填写电子邮件或用户名的框中导航,然后复制x_path。
- 然后浏览密码,然后复制x_path。
- 然后浏览登录按钮,然后复制x_path。
执行:
from selenium import webdriver from selenium.webdriver.common.keys import Keys import time # create instance of Chrome webdriver driver = webdriver.Chrome() driver.get("https://auth.geeksforgeeks.org/") # find the element where we have to # enter the xpath # fill user or mail id driver.find_element_by_xpath('//*[@id ="luser"]').send_keys('praveeny182') # find the element where we have to # enter the xpath # fill password driver.find_element_by_xpath('//*[@id ="password"]').send_keys('xXXXXX') # find the element sign in # request using xpath # clicking on that element driver.find_element_by_xpath('//*[@id ="Login"]/button').click()
输出 –
您最终将在运行selenium的浏览器中登录到geeksforgeeks。