Multiple attribute values from xpath

35 views
Skip to first unread message

Jonn Doe

unread,
May 10, 2024, 6:23:02 AMMay 10
to Selenium Users

If I want to get the text from an a tag which is under a div i'd do....

elem = driver.find_element(By.XPATH,'//div/a).text

But what I want is the text and the href. The reason being I don't want to iterate over a huge list getting each a.href and a.text as it is slow I want to the browser to do the work upfront and hope its quicker, so is it possible getting multiple attributes from a xpath ?

Thank you.
E

Nortier David

unread,
May 13, 2024, 2:47:06 AMMay 13
to seleniu...@googlegroups.com

Hello

 

Yes you can 😊

 

See the ‘and/or’ fonctions

 

Ex: .FindElement(How.XPath, "//*[contains(@class, 'menu') and text()='History']"));

 

 

 

De : seleniu...@googlegroups.com <seleniu...@googlegroups.com> De la part de Jonn Doe
Envoyé : vendredi 10 mai 2024 12:23
À : Selenium Users <seleniu...@googlegroups.com>
Objet : [selenium-users] Multiple attribute values from xpath

 

ATTENTION : cet e-mail provient d'une personne externe. Vérifiez toujours l’expéditeur avant d’ouvrir les pièces jointes ou de cliquer sur les liens.

--
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/f3229458-631c-49e3-842b-abfcb1c403d2n%40googlegroups.com.


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

https://www.cph.be/maildisclaimer

Reply all
Reply to author
Forward
0 new messages