Alp Akova Student
Alp Akova Student

Reputation: 13

Selenium button click with Python

I'm pretty new to programming and Зython so trying to learn more by projects. Currently, workıng on Selenium and trying to automate my Steam login. The code looks like this. parts about the username and password inputs seem to working. I tried several different find methods for my button click but not worked. Using Chrome as a browser. I need some help on how to make that button click work. Thank you.

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()

Upvotes: 1

Views: 82

Answers (1)

SeleniumUser
SeleniumUser

Reputation: 4177

find_elements_by_class_name will return a list of elements and handle all elements within that list you need to iterate through your list. Currently, you are trying to handle a single web element so you can use find_element_by_class_name to retrieve your desired element, and then you can perform an action on it.

element = browser.find_element_by_class_name("btnv6_blue_hoverfade  btn_medium")

Upvotes: 2

Related Questions