Paz*_*Paz 7 python selenium click
我试图点击这个按钮移动到登录页面。我的代码是:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('http://moodle.tau.ac.il/')
Run Code Online (Sandbox Code Playgroud)
那很好用,但我只能通过使用找到表格
loginform = driver.find_element_by_xpath("//form[@id='login']/")
Run Code Online (Sandbox Code Playgroud)
我不知道如何到达按钮,这是非常基本的东西,但我没有找到任何好的例子。
这将单击moodle.tau.ac.il 页面上的登录按钮。该行driver.find_element_by_xpath(".//*[@id='login']/div/input").click()找到页面上的登录按钮并单击它。Xpath 只是一种选择器类型,您可以将其与 selenium 一起使用来查找页面上的 Web 元素。您还可以使用 ID、类名和 CSS 选择器。
from selenium import webdriver
driver = new webdriver.Chrome()
driver.get('moodle.tau.ac.il')
# This will take you to the login page.
driver.find_element_by_xpath(".//*[@id='login']/div/input").click()
# Fills out the login page
elem = driver.find_element_by_xpath("html/body/form/table/tbody/tr[2]/td/table/tbody/tr[1]/td[2]/input")
elem.send_keys('Your Username')
elem = driver.find_element_by_xpath("html/body/form/table/tbody/tr[2]/td/table/tbody/tr[3]/td[2]/input")
elem.send_keys('Your ID Number')
elem = driver.find_element_by_xpath("html/body/form/table/tbody/tr[2]/td/table/tbody/tr[1]/td[2]/input")
elem.send_keys('Your Password')
driver.find_element_by_xpath("html/body/form/table/tbody/tr[2]/td/table/tbody/tr[7]/td[2]/input").click()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17895 次 |
| 最近记录: |