Selenium Python - click on a link inside <a herf

Stack Overflow Asked by hadi0815 on January 5, 2022

It is a very unique situation that I can’t get it to work out. after logging into the website I want my code go and click on one of the times in the left side menu bar which has below element:

            <span class="hide-on-toggle" style="color: #225515;margin-left:10px;">GO</span>
            <li class="hide-on-toggle jizzzHidden">
                <a href="/JIZZZ" target="_blank">
                  <span class="fa-stack fa-lg">
                    <i><img src="/resource/153270/images/logo.png">
            <li class="hide-on-toggle">
                <a href="https://login.html?serviceIier" target="_blank">
                  <span class="fa-stack fa-lg">
                    <i class="fa fa-desack-1x "></i>
                  </span> joozz

So here is my code so far

from selenium import webdriver
from import By
from import WebDriverWait
from selenium.webdriver.common.keys import Keys
from import expected_conditions
from import Select
from selenium.webdriver import ActionChains

driver = webdriver.Chrome()

username = driver.find_element_by_id("username")

password = driver.find_element_by_name("password")



I get an error of :

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//span[text()='JIZZZ']"}

I also tried


but got error of :

AttributeError: 'WebDriver' object has no attribute 'find_element_by_XPath'

I am lost and appreciate any help.

One Answer

driver.find_element_by_xpath("//span[contains(text(), 'JIZZZ')]").click()

Answered by Cameron Russell on January 5, 2022

Add your own answers!

Related Questions

Bluehost hosted React pages not found

0  Asked on November 10, 2021 by paul-lindberg


Change a view margins programmatically

4  Asked on November 10, 2021 by m-r_dino


React returning view from switch statement

1  Asked on November 10, 2021 by mattblack


Find string then return different row value Python

0  Asked on November 10, 2021 by newtothecrew


React JS – route does not pick the required Component

0  Asked on November 10, 2021 by nirjal-paudel


get character after space of array value on javascript

9  Asked on November 7, 2021 by riko-pramayudi


Ask a Question

Get help from others!

© 2023 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP