Help xpath

36 views
Skip to first unread message

Jaemerson Brito Souza

unread,
Jan 1, 2025, 12:39:01 AM1/1/25
to Selenium Users
Hello!
How can I get the value ["17:30,10/12/2024"] from the element "class=copyable-text"?
I've already tried
e.FindElement(By.XPath(".//*[contains(@class,\"x9f619\")]"));
e.FindElement(By.XPath(".//*[contains(@class,\"copyable-text\")]"));
e.FindElement(By.XPath("//*[contains(@class,\"copyable-text\")]"));

But when I search for the text property, I only get the value "18:00 ???"
selenium.jpg

ebubekir bastama

unread,
Jan 1, 2025, 2:50:06 AM1/1/25
to seleniu...@googlegroups.com

This expression selects the first element with class="copyable-text" in the HTML and retrieves the value of its data-pre-plain-text attribute. If you run this XPath in a browser console, it should correctly return the value ["17:30, 10/12/2024"].

The other XPath expressions you tried might have selected the element, but without using getAttribute("data-pre-plain-text"), they wouldn’t have retrieved the attribute value directly.

$x("//*[@class='copyable-text']")[0].getAttribute("data-pre-plain-text")


Jaemerson Brito Souza <jaj...@gmail.com>, 1 Oca 2025 Çar, 08:38 tarihinde şunu yazdı:
--
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 visit https://groups.google.com/d/msgid/selenium-users/3d18198f-dd8c-487c-9274-248a2c3a8a02n%40googlegroups.com.

Jaemerson Real Lubrificantes

unread,
Jan 1, 2025, 3:35:26 PM1/1/25
to seleniu...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages