0

I'm struggling with an automation task where the HTML site has an input field, but when I search it out in DOM Explorer it looks like this:

<input name="txtFirewall" id="txtFirewall" type="text">

As you can see, there is no value attribute. Once you give in smthing manually to the search field it changes like this:

<input name="txtFirewall" id="txtFirewall" type="text">value="Something">

How can I add the Value attribute and assign value to it with python? Can it be even done with Selenium?

2

2 Answers 2

1

This code can help you:

search_field = driver.find_element_by_id("txtFirewall")
search_field.send_keys("Something")

Hope it helps you!

Sign up to request clarification or add additional context in comments.

Comments

0

To add the value attribute and assign the value 'Something' to it you can use the following code block :

element = driver.find_element_by_css_selector("input#txtFirewall.txtFirewall")
driver.execute_script("arguments[0].setAttribute('value','Something')", element)

Comments

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.