Selecting xpath for with multiple conditions using Selenium and Python

0 votes

I'm trying to select an element based on multiple conditions but it is throwing an error

choices = driver.find_elements_by_xpath("//div[contains(.,'5') and [contains(@class, 'option')]]")$

Any suggestions??

Jul 13, 2018 in Selenium by Martin
• 4,320 points
29,731 views

1 answer to this question.

0 votes

Use the XPath in either of the following ways :

choices = driver.find_elements_by_xpath("//div[contains(.,'5') and contains(@class, 'option')]")

 or

choices = driver.find_elements_by_xpath("//div[contains(.,'5')][contains(@class, 'option')]")

For further understanding, you can refer to the Selenium Course.

answered Jul 13, 2018 by Samarpit
• 5,910 points

Related Questions In Selenium

0 votes
1 answer

Need to perform parallel execution (multiple browser sessions) with Selenium & TestNG by using @BeforeSuite

@Beforesuite annotated method runs before the testNG.XML ...READ MORE

answered Mar 30, 2018 in Selenium by nsv999
• 5,500 points
5,976 views
0 votes
1 answer

Using XPath with Selenium-Java code

There is a minor syntax error in ...READ MORE

answered Apr 14, 2018 in Selenium by king_kenny
• 3,710 points
983 views
0 votes
1 answer

XPath for the elements with no ID or Name in Selenium Webdriver

Use like this or similar to this: //div[@id="top-level-menu-item-3"]/div[@class="filter-label"] //div[@id="top-level-menu1"] ...READ MORE

answered Apr 17, 2018 in Selenium by Meci Matt
• 9,460 points
7,315 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,567 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,084 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,178 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,840 views
0 votes
1 answer

How to get next sibling element using XPath and Selenium for Java?

Below code will help you: Try following-sibling axis : WebElement ...READ MORE

answered May 15, 2018 in Selenium by Samarpit
• 5,910 points
20,775 views
0 votes
1 answer

How to login a forum using Selenium with Python

You should try to directly log in ...READ MORE

answered Apr 27, 2018 in Selenium by Samarpit
• 5,910 points
2,693 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP