2

I am working with website built with Facebook React JS Library. I want to test if a input form is populated with a text or to use it in unittest method. I tried this but this does not work at all. Problem is my given input data is not in the that DOM even not the page source.

In this case how to check if input-form is filled?

demo

1 Answer 1

2

Locate the input element and get the value attribute:

district = driver.find_element_by_css_selector("input[label=District]")
print(district.get_attribute("value"))

You might also need to wait for that element to become visible first:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

wait = WebDriverWait(driver, 10)
district = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "input[label=District]")))
print(district.get_attribute("value"))
Sign up to request clarification or add additional context in comments.

1 Comment

@SIslam sure, it's just that this is an input element and the value you see in the input is held inside the value attribute and not the element's text..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.