You would have to use the JavascriptExecutor class:
WebDriver driver; // Assigned elsewhere
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("document.getElementById('//id of element').setAttribute('attr', '10')");
More Related Contents:
- How to identify and switch to the frame in selenium webdriver when frame does not have id
- HTTP Basic Auth via URL in Firefox does not work?
- Running multiple Selenium tests at the same time
- HTTP Web Site Automation Testing without UI [closed]
- Python Selenium wait for several elements to load
- What’s the difference between unit, functional, acceptance, and integration tests? [closed]
- How to upload file ( picture ) with selenium, python
- Switch tabs using Selenium WebDriver with Java
- Check if any alert exists using selenium with python
- Select -> option abstraction
- Can I run multiple versions of Google Chrome on the same machine? (Mac or Windows)
- What is The Turkey Test?
- Separate ‘debug’ and ‘release’ builds?
- Tools for Generating Mock Data? [closed]
- What is an idiomatic way to have shared utility functions for integration tests and benchmarks?
- What is code coverage and how do YOU measure it?
- Tool to compare large numbers of PDF files? [closed]
- karate.callSingle not found .feature file in karate-config.js
- Why should I practice Test Driven Development and how should I start?
- How to explain sorting (numerical, lexicographical and collation) with examples to non technical testers?
- Order of execution of tests in TestNG
- Gradle: How to Display Test Results in the Console in Real Time?
- How to test a function’s output (stdout/stderr) in unit tests
- How to prepare a nested data structure for a data-driven test in Karate?
- What is the difference between integration testing and functional testing? [closed]
- Selenium WebDriver throws Timeout exceptions sporadically
- Selenium WebDriver StaleElementReferenceException
- How to `go test` all tests in my project?
- Mocking USB input
- When should I use Debug.Assert()?