Automation Testing Articles

Page 2 of 62

How to simulate pressing enter in html text input with Selenium?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 16-Mar-2026 865 Views

We can simulate pressing enter in HTML text input fields using Selenium WebDriver. The sendKeys method allows us to send key presses to web elements, including the Enter key. This is commonly used for form submissions, search operations, or triggering input validation. Syntax Following is the syntax to simulate pressing Enter using Selenium − element.sendKeys(Keys.ENTER); Alternatively, you can use Keys.RETURN which produces the same result − element.sendKeys(Keys.RETURN); Both Keys.ENTER and Keys.RETURN represent the same key press action and can be used interchangeably in Selenium automation. Required Import To ...

Read More

How to get HTML code of a WebElement in Selenium?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 16-Mar-2026 6K+ Views

We can get the HTML code of a WebElement using Selenium WebDriver by accessing the innerHTML attribute. The innerHTML represents the HTML content between the opening and closing tags of an element, which includes both text content and any nested HTML elements. The getAttribute() method is used to retrieve the innerHTML value by passing "innerHTML" as a parameter. This method returns the complete HTML markup contained within the selected element. Syntax Following is the syntax to get the innerHTML of a WebElement − String htmlContent = element.getAttribute("innerHTML"); Where element is the WebElement object ...

Read More

Getting the return value of Javascript code in Selenium.

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 15-Mar-2026 4K+ Views

We can get the return value of Javascript code with Selenium WebDriver using the executeScript method. This method executes JavaScript commands in the browser and can return values back to our Java code. To work with JavaScript in Selenium, we need to cast our WebDriver instance to JavascriptExecutor and import the necessary package. The JavaScript command is passed as a string argument to the executeScript method. Syntax JavascriptExecutor js = (JavascriptExecutor) driver; Object result = js.executeScript("return document.getElementById('elementId').value"); Key Points When working with JavaScript return values in Selenium: Use the return keyword ...

Read More

Reading JavaScript variables using Selenium WebDriver.

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 15-Mar-2026 3K+ Views

We can read JavaScript variables with Selenium WebDriver using the executeScript method. This method allows Selenium to execute JavaScript commands directly in the browser and return their results. To work with JavaScript in Selenium, we need to import org.openqa.selenium.JavascriptExecutor. Syntax JavascriptExecutor j = (JavascriptExecutor) driver; String result = (String) j.executeScript("return document.title"); Reading Document Properties The most common use case is reading document properties like title, URL, or DOM elements. Let's obtain the browser title by reading the JavaScript variable document.title. Example Here's a complete example that reads the page title ...

Read More

Capturing JavaScript error in Selenium.

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 15-Mar-2026 2K+ Views

We can capture JavaScript errors in Selenium WebDriver to identify console errors that appear in the browser's Developer Tools. These errors can occur due to functional issues on the page or performance problems caused by excessive logging. JavaScript errors are typically visible in the Console tab of browser Developer Tools and can impact application functionality. Selenium provides logging capabilities to capture and analyze these errors programmatically. Browser Developer Tools - Console Tab ...

Read More

Wait for complex page with JavaScript to load using Selenium.

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 15-Mar-2026 3K+ Views

We can wait for a complex page with JavaScript to load with Selenium. After the page is loaded, we can invoke the Javascript method document.readyState and wait till complete is returned. Understanding document.readyState The document.readyState property returns the loading status of the document. It has three possible values: loading - The document is still loading interactive - Document has finished loading but sub-resources may still be loading complete - The document and all sub-resources have finished loading Syntax JavascriptExecutor js = (JavascriptExecutor)driver; js.executeScript("return document.readyState").toString().equals("complete"); Method 1: Using document.readyState Check ...

Read More

How to get the value of the edit box in Selenium?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 15-Mar-2026 652 Views

In Selenium WebDriver, retrieving values from edit boxes (input fields) requires specific methods since getText() often returns empty strings for input elements. Here are the most effective approaches to extract values from edit boxes. Why getText() May Not Work The getText() method retrieves visible text content, but input fields store their values in the "value" attribute rather than as text content. This is why getText() often returns empty strings for input elements. Method 1: Using getAttribute("value") The most reliable approach is using the getAttribute() method to retrieve the "value" attribute: import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; ...

Read More

Differences between Interface and Integration Testing.

Mahesh Parahar
Mahesh Parahar
Updated on 14-Mar-2026 2K+ Views

Testing is crucial in software delivery, as it validates quality and helps developers improve their product. Two important testing types are Integration Testing and Interface Testing. Integration testing verifies that multiple components work together correctly, while interface testing focuses on the communication channels (APIs, web services) between those components. Integration Testing Integration testing is performed after unit testing to verify that individual components work correctly when combined in an integrated environment. It tests the end-to-end functionality of all components working together. Integration testing can be done in several approaches − Big Bang (all at once), Top-Down, Bottom-Up, or ...

Read More

Getting console.log output from Chrome with Selenium Python API bindings.

Akshitha Mote
Akshitha Mote
Updated on 22-Jan-2025 6K+ Views

We can get console.log output from Chrome with Selenium Python API bindings. We will perform this with the DesiredCapabilities class. We shall enable logging from the browser with DesiredCapabilities.Chrome setting. We have to pass this browser capability to the driver object by passing it as a parameter to the Chrome class. To enable logging we shall set the property goog:loggingPrefs of the browser to 'browser':'ALL'. Syntax Syntax:dc = DesiredCapabilities.CHROME dc['goog:loggingPrefs'] = { 'browser':'ALL' } driver = webdriver.Chrome(desired_capabilities=dc) Example from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities #set browser log dc = DesiredCapabilities.CHROME dc['goog:loggingPrefs'] = { 'browser':'ALL' } driver ...

Read More

GUI Testing Tutorial: User Interface (UI) Test Cases with Examples

Vineet Nanda
Vineet Nanda
Updated on 30-Oct-2024 8K+ Views

What is a GUI? For a computer application, there are two sorts of interfaces. The Command Line Interface (CLI) is a program that allows you to write text and have the computer reply to it. The Graphical User Interface (GUI) is a method of interacting with a computer that uses graphics rather than words. The following are some of the graphical user interface components that may be used to interact with the application − Radio Button ...

Read More
Showing 11–20 of 618 articles
« Prev 1 2 3 4 5 62 Next »
Advertisements