Execute JavaScript in the page
Hard120 pts~45 min
- JavaScript execution
- Script arguments
Practice app · Document Vault
File upload and download, cookies, localStorage, sessionStorage and JavaScript execution.
Your starter code already declares TEST_URL — never hardcode a host.
Objective
Use executeScript to read page state and to change an element, passing the element as an argument.
Your task
- 1Assert executeScript("return document.title") returns “Documents | TargetQA Practice”.
- 2Find #js-target and assert it reads “Original text”.
- 3Run executeScript("arguments[0].textContent = 'Changed by WebDriver'", element).
- 4Assert #js-target now reads “Changed by WebDriver”.
Acceptance criteria
- executeScript returns a value and receives an element argument
- #js-target shows “Changed by WebDriver”
- At least 2 assertions pass
Selenium WebDriver 4 · Selenium · Files, windows & storage