Selenium locating elements by more than one method
You can use xpath to combine both selectors:
driver.find_elements_by_xpath("//*[@class='iUh30'][text()[contains(.,'html')]]")
The //* looks for any element with any tag. Might be <a>, might be <div>, <input>, anything. You can just change it to the desired tag.
The above find the element by exact class name. You can also use [contains(@class, 'partial_class')] to find elements by partial class.
The [text()[contains(.,'html')]] looks for elements which partial text is "html"
I'm using Selenium to locate elements in a page. Is there any way to combine two methods together?
Example:
Method 1: driver.find_elements_by_partial_link_text('html')
Method 2: driver.find_elements_by_class_name('iUh30')
I will ideally like a method that finds elements that has both the partial link text and class name specified.