Find element by text

236 views
Skip to first unread message

Huus Huusk

unread,
Jan 12, 2023, 11:01:49 PM1/12/23
to Selenium Users
HI i want to find element by the text inner span class.  driver.find_element_by_css_selector("span[class='input_group_button']")
driver.findElement(By.partialLinkText("Write"));
these 2 method not working can u guys help me?

Nortier David

unread,
Jan 13, 2023, 3:55:24 AM1/13/23
to seleniu...@googlegroups.com

What about the error ?

 

De : seleniu...@googlegroups.com <seleniu...@googlegroups.com> De la part de Huus Huusk
Envoyé : vendredi 13 janvier 2023 04:28
À : Selenium Users <seleniu...@googlegroups.com>
Objet : [selenium-users] Find element by text

 

HI i want to find element by the text inner span class.  driver.find_element_by_css_selector("span[class='input_group_button']")

driver.findElement(By.partialLinkText("Write"));

these 2 method not working can u guys help me?

 

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/6ddf45ab-e7dc-4a2c-9a92-7f2e0dc0c899n%40googlegroups.com.


====== DISCLAIMER ======

https://www.cph.be/maildisclaimer

Huus Huusk

unread,
Jan 13, 2023, 4:02:13 AM1/13/23
to Selenium Users

DevTools listening on ws://127.0.0.1:51784/devtools/browser/b224726c-b501-4109-9aa6-ee7b23c5577d
Traceback (most recent call last):
  File "c:\Users\EnkhkhuslenEnkhtur\OneDrive - ICT Group JSC\Desktop\Huslen python\test.py", line 30, in <module>
    close_icon = driver.find_element(By.PARTIAL_LINK_TEXT, "ХЭСГИЙН АХЛАГЧИЙН СИСТЕМ").click()
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\EnkhkhuslenEnkhtur\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 861, in
find_element
    return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\EnkhkhuslenEnkhtur\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 444, in
execute
    self.error_handler.check_response(response)
  File "C:\Users\EnkhkhuslenEnkhtur\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 249,
in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"partial link text","selector":"ХЭСГИЙН АХЛАГЧИЙН СИСТЕМ"}
  (Session info: chrome=108.0.5359.125)
Stacktrace:
Backtrace:
        (No symbol) [0x010EF243]
        (No symbol) [0x01077FD1]
        (No symbol) [0x00F6D04D]
        (No symbol) [0x00F9C0B0]
        (No symbol) [0x00F9C22B]
        (No symbol) [0x00FCE612]
        (No symbol) [0x00FB85D4]
        (No symbol) [0x00FCC9EB]
        (No symbol) [0x00FB8386]
        (No symbol) [0x00F9163C]
        (No symbol) [0x00F9269D]
        GetHandleVerifier [0x01389A22+2655074]
        GetHandleVerifier [0x0137CA24+2601828]
        GetHandleVerifier [0x01198C0A+619850]
        GetHandleVerifier [0x01197830+614768]
        (No symbol) [0x010805FC]
        (No symbol) [0x01085968]
        (No symbol) [0x01085A55]
        (No symbol) [0x0109051B]
        BaseThreadInitThunk [0x776100F9+25]
        RtlGetAppContainerNamedObjectPath [0x77AF7BBE+286]
        RtlGetAppContainerNamedObjectPath [0x77AF7B8E+238]

Huus Huusk

unread,
Jan 13, 2023, 4:03:06 AM1/13/23
to Selenium Users
Thank you for your responding. Can i find element by text? 

On Friday, January 13, 2023 at 4:55:24 PM UTC+8 n...@cph.be wrote:

Nortier David

unread,
Jan 13, 2023, 4:14:56 AM1/13/23
to seleniu...@googlegroups.com

Yes you can

 

·         By.XPath

 

o   The entire text                   "//button[text()=’what-you-search’]"

 

o   A part of the text               "//span[contains(text(), ‘what-you-search’]"

 

 

 

De : seleniu...@googlegroups.com <seleniu...@googlegroups.com> De la part de Huus Huusk
Envoyé : vendredi 13 janvier 2023 10:03
À : Selenium Users <seleniu...@googlegroups.com>
Objet : Re: [selenium-users] Find element by text

Huus Huusk

unread,
Jan 13, 2023, 4:16:59 AM1/13/23
to Selenium Users
I already tried that way but still not working. And the error is: STR is not callable 😢

Nortier David

unread,
Jan 13, 2023, 5:01:15 AM1/13/23
to seleniu...@googlegroups.com

I don’t know Python

 

Add Python in the object of the mail, to find specialists 😊

 

 

I found this :

 

Python typeerror: ‘str’ object is not callable Solution - DEV Community 👩💻👨💻

 

De : seleniu...@googlegroups.com <seleniu...@googlegroups.com> De la part de Huus Huusk
Envoyé : vendredi 13 janvier 2023 10:17

Chandrika sai

unread,
Jan 13, 2023, 6:06:16 AM1/13/23
to seleniu...@googlegroups.com
For this error, need to see the context or requirement. 

I guess, in the identification of the element only, the wrong will be.
so, try to locate the element once again correctly.

Reply all
Reply to author
Forward
0 new messages