Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selenium Articles
Found 362 articles
Moving mouse pointer to a specific location or element using C# and Selenium
We can move mouse pointer to a specific location or element in Selenium WebDriver with C# using the Actions class. This class provides methods to simulate user interactions like moving the mouse, clicking, and performing complex gestures on web elements. To move the mouse to an element, we use the MoveToElement method and pass the element locator as a parameter. To move to specific coordinates, we use the MoveByOffset method. All actions must be executed using the Perform method. Syntax Following is the syntax for creating an Actions object and moving to an element − ...
Read MoreHow to open a browser window in full screen using Selenium WebDriver with C#?
We can open a browser window in full screen using Selenium WebDriver in C# by using the Maximize() method. This method is applied on the WebDriver object through the window management interface and expands the browser to fill the entire screen. Syntax Following is the syntax for maximizing a browser window − driver.Manage().Window.Maximize(); For setting specific window size, you can also use − driver.Manage().Window.Size = new Size(width, height); Using Maximize() Method The Maximize() method is the most common approach to open a browser in full screen mode. It automatically ...
Read MoreAccessing HTML source code using Python Selenium.
We can access HTML source code with Selenium WebDriver using two primary methods. The page_source method retrieves the complete HTML of the current page, while JavaScript execution allows us to access specific portions of the DOM, such as the body content. Syntax Following is the syntax for accessing HTML source using the page_source method − src = driver.page_source Following is the syntax for accessing HTML source using JavaScript execution − h = driver.execute_script("return document.body.innerHTML") Method 1: Using page_source Method The page_source method returns the complete HTML source code of ...
Read MoreHow to set style display of an html element in a selenium test?
We can set the style display of an HTML element with Selenium WebDriver using JavaScript execution. The DOM interacts with page elements through JavaScript, and Selenium executes JavaScript commands using the executeScript method. This approach is particularly useful when you need to modify CSS properties like visibility, display type, or other styling attributes programmatically during test execution. Some operations like setting the style display must be performed by JavaScript Executor. The getElementById method locates the element, then we apply the style.display property to set the display type such as block, none, inline, or flex. Syntax Following is ...
Read MoreHow to simulate pressing enter in html text input with Selenium?
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 MoreHow to get HTML code of a WebElement in Selenium?
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 MoreGetting the return value of Javascript code in Selenium.
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 MoreReading JavaScript variables using Selenium WebDriver.
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 MoreRetweet Tweet using Selenium in Python
Python has become one of the most popular programming languages, renowned for its versatility and extensive libraries. When it comes to automating web tasks, Python offers a powerful tool called Selenium. Selenium allows us to interact with web browsers programmatically, making it an excellent choice for automating tasks like retweeting tweets on platforms like Twitter. By using both Python and Selenium, we can streamline our web browsing experience and effortlessly engage with the content we find interesting. In this tutorial, we will explore the fascinating world of retweeting tweets using Selenium in Python. Throughout the article, we will guide you ...
Read MoreScrape LinkedIn Using Selenium And Beautiful Soup in Python
Python has emerged as one of the most popular programming languages for web scraping, thanks to its rich ecosystem of libraries and tools. Two such powerful libraries are Selenium and Beautiful Soup, which, when combined, provide a robust solution for scraping data from websites. In this tutorial, we will delve into the world of web scraping with Python, specifically focusing on scraping LinkedIn using Selenium and Beautiful Soup. In this article, we will explore the process of automating web interactions using Selenium and parsing HTML content with Beautiful Soup. Together, these tools enable us to scrape data from LinkedIn, the ...
Read More