简体   繁体   English

我无法使用 selenium 找到并单击 HTML 按钮

[英]I can't locate and click on a HTML button using selenium

I am trying to create a program that opens a URL and then clicks on the "Memberships" button on that page.我正在尝试创建一个打开 URL 的程序,然后单击该页面上的“会员资格”按钮。 My program can open up the URL but doesn't locate or click on the membership button.我的程序可以打开 URL,但找不到或单击会员按钮。 I am new to code and can't find out what is wrong with the code.我是代码新手,无法找出代码有什么问题。 The code is below.代码如下。 Any help would be appreciated.任何帮助,将不胜感激。

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.keys import Keys

s=Service("C:\Program Files (x86)\chromedriver.exe")
driver = webdriver.Chrome(service=s)
url='https://tickets.leedsunited.com/'
driver.get(url)
link = driver.find_element("Memberships")
link.click()

find_element method should receive 2 arguments: locator type and value . find_element方法应该接收 2 个参数: 定位器类型和值 Correct code should be正确的代码应该是

driver.find_element("link text", "Memberships").click()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM