How to check whether the element text contains some text with python selenium?
You can wait for element like this :
from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(driver, 10)
element = wait.until(EC.visibility_of_element_located((By.ID, 'someid')))
extract the text like this :
actual_text = element.text
check whether it contains expected text or not like this:
self.assertIn('expected_string_here', actual_text)
or like this :
print expected_string_here == actual_text
How to find all elements that contains a value in a specific attribute using selenium python
The below xpath
//*[contains(@style,'display: none')]
should represent all the node which are having style as display none
.
for this specific div
, you can have //*
replaced with //div
. Something like this :
//div[contains(@style,'display: none')]
sample code :
disp_none = driver.find_element_by_xpath("//*[contains(@style,'display: none')]")
the above list disp_none
should contains all the web elements.
Print the size like this :
print(len(disp_none))
Related Topics
Different Behaviour for List._Iadd_ and List._Add_
Main() Function Doesn't Run When Running Script
How to Get User Ip Address in Django
How to Initialize a Two-Dimensional Array in Python
Pandas: Filter Rows of Dataframe with Operator Chaining
Numpy Array Is Not JSON Serializable
Finding Local Maxima/Minima with Numpy in a 1D Numpy Array
Plot Logarithmic Axes with Matplotlib in Python
Replace Non-Ascii Characters with a Single Space
Method Resolution Order (Mro) in New-Style Classes
How to Filter a Dictionary According to an Arbitrary Condition Function
How to Create a Copy of an Object in Python
Why Does (1 in [1,0] == True) Evaluate to False
How to Turn a Python Datetime into a String, with Readable Format Date
The 'Is' Operator Behaves Unexpectedly with Non-Cached Integers
How to Convert Surrogate Pairs to Normal String in Python
How to Print Original Variable's Name in Python After It Was Returned from a Function