Using Window Location in JavaScript
One powerful feature of JavaScript is the ability to manipulate the browser window using the window.location
object. This object allows you to access and modify various aspects of the current page address, such as the URL, domain name, path, filename, and web protocol. You can even use it to load a new document.
window.location.href
: returns the current page's URL
window.location.hostname
: returns the domain name of the host
window.location.pathname
: returns the path and filename of the page
window.location.protocol
: returns the web protocol (http: or https:)
window.location.assign
: loads a new document
Determining If Page Has Fully Loaded
Checking if a page has fully loaded through Selenium can be tricky, as there is no one-size-fits-all solution. However, there are strategies you can employ to ensure that the page has completely loaded:
pageLoadStrategy
- Wait for the Browser Client to reach a state where 'document.readyState' equals "complete"
- Utilize WebDriverWait in combination with ExpectedConditions, such as:
urlContains()
: Expectation for the URL to contain specific text
urlMatches()
: Expectation for the URL to match a regular expression
urlToBe()
: Expectation for the URL to be a specific URL
Note: For more insights, refer to the discussion on checking if a page has fully loaded in Selenium here