1

example:

<input type="text" id="cargo_q" autocomplete="off" value="5.5"/> How to change the value of "value" attribute using selenium web driver

Is there any method like: IWebElement search_cargo =driver.FindElement(By.Id("cargo_q"))); search_cargo.setAttribute(attribute name,attribute new value); " ?

1 Answer 1

1

Use the JavascriptExecutor class:

JavascriptExecutor js = (JavascriptExecutor) driver; //Driver is the WebDriver object
js.executeScript("document.getElementById('cargo_q').setAttribute('value', '10')");
Sign up to request clarification or add additional context in comments.

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.