In order to interact with the entire page source in Python, you need to use the page_source property of the WebDriver. This script shows a basic operation that uses the page_source property to search for a specific string.
There are three ways of waiting for elements: explicit wait, implicit wait and fluent wait.
Explicit wait waits until either a certain condition is met or the timeout has been reached before attempting to return an element.
The following code shows how to open a link in a new tab using Keys.chord(...) in the first test method. This code more accurately models human behaviour compared to the following example as it directly models human behaviour.
To get the text entered into an input element, use element.getAttribute("value") where element is the input element. The attribute text is used to get the text from the tags within an element.
WebElement query = driver.findElement(By.id("searchInput")); query.sendKeys("the moon"); System.out.println(query.getAttribute("value"));
To mouse over elements, you need to use the Actions class to build and perform the MoveToElement command.