Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Python单击Selenium按钮_Python_Python 3.x_Selenium_Automation_Selenium Chromedriver - Fatal编程技术网

使用Python单击Selenium按钮

使用Python单击Selenium按钮,python,python-3.x,selenium,automation,selenium-chromedriver,Python,Python 3.x,Selenium,Automation,Selenium Chromedriver,我对编程非常陌生,所以我试图通过项目学习更多。目前,我正在研究Selenium并尝试自动登录我的Steam。代码如下所示。有关用户名和密码输入的部分似乎正在工作。我尝试了几种不同的按钮点击查找方法,但没有成功。使用Chrome作为浏览器。我需要一些关于如何使按钮点击工作的帮助。多谢各位 def login(): browser.get("URL") browser.find_element_by_id("input_username").send_keys("username"

我对编程非常陌生,所以我试图通过项目学习更多。目前,我正在研究Selenium并尝试自动登录我的Steam。代码如下所示。有关用户名和密码输入的部分似乎正在工作。我尝试了几种不同的按钮点击查找方法,但没有成功。使用Chrome作为浏览器。我需要一些关于如何使按钮点击工作的帮助。多谢各位

def login():

    browser.get("URL")
    browser.find_element_by_id("input_username").send_keys("username")
    browser.find_element_by_id("input_password").send_keys("pasword")
    element = browser.find_elements_by_class_name("btnv6_blue_hoverfade  btn_medium")
    element.click()


login()

find_elements\u by_class_name
将返回元素列表,并处理该列表中需要迭代的所有元素。目前,您正在尝试处理单个web元素,以便可以使用
find\u element\u by\u class\u name
检索所需的元素,然后对其执行操作

element = browser.find_element_by_class_name("btnv6_blue_hoverfade  btn_medium")

好的,请你从你这边回答。