Search code examples
pythonseleniumauthenticationhref

Can't click the login button with Selenium


I have tried using .click(), .submit() and driver.get(), but nothing seems to work. The site is gosgc.com

The <div is:

<!-- -->
<div_ngcontent-c1=""class="user user--login">
<a_ngcontent-c1=""class="recover-username"href="/recover- user"routerlink="/recover-user" routerlinkactive="menu__item-- 
active">Forgot Username?</a>
<a_ngcontent-c1=""class="button">Login</a>
</div>

Thank you for your help!


Solution

  • Please try one of the following:

    # catching the element (login button) using xpath
    driver.find_element_by_xpath("/html/body/sgc-web/div/general- layout/div/div/div[3]/a[2]").click()
    
    # catching the element (login button) using CSS Selector
    driver.find_element_by_css_selector("body > sgc-web > div > general-layout > div > div > div.user.user--login > a.button").click()
    
    # catching the element (login button) using class name
    driver.find_element_by_class_name("button").click()
    
    # catching the element (login button) using link text
    driver.find_element_by_link_text("Login").click()