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
Articles by Debomita Bhattacharjee
590 articles
How to trigger headless test execution in Selenium with Python?
Selenium supports headless execution, allowing browser automation to run without a visible GUI. This is useful for automated testing, server environments, or when you don't need to see the browser window. In Chrome, headless mode is implemented using the ChromeOptions class. Setting Up Headless Chrome To enable headless mode, create a ChromeOptions object and add the --headless argument ? from selenium import webdriver from selenium.webdriver.chrome.options import Options # Create ChromeOptions object chrome_options = Options() # Enable headless mode chrome_options.add_argument("--headless") # Initialize driver with headless options driver = webdriver.Chrome(options=chrome_options) try: ...
Read MoreHow to set window size using phantomjs and selenium webdriver in Python?
We can set window size using PhantomJS and Selenium webdriver in Python. PhantomJS is a headless browser that allows automated testing without displaying a GUI. To work with PhantomJS, we create a driver object of the webdriver.PhantomJS class and pass the path to the phantomjs.exe driver file as a parameter. To set the window size, we use the set_window_size method and pass the width and height dimensions as parameters. We can also retrieve the current window size using the get_window_size method. Syntax driver.set_window_size(width, height) print(driver.get_window_size()) Parameters width − The desired window width ...
Read MoreRunning Selenium Webdriver with a proxy in Python.
We can run a proxy with Selenium webdriver in Python. A proxy is an essential component to do localization testing. We can take an e-commerce application and check if the language and currency visible is as per the user location. With the help of proxy within tests, we can verify if the website user interface matches with the location. We have to set a proxy with below steps − Import webdriver from Selenium package. Define proxy server address. Create an object of ChromeOptions class Communication of proxy with ChromeOptions. Summing options to Chrome() object. Basic ...
Read MoreSelenium and Python to find elements and text?
We can find elements and extract their text with Selenium webdriver. First, identify the element using any locator like id, class name, CSS selector, or XPath. Then use the text property to obtain the text content. Syntax element_text = driver.find_element(By.CSS_SELECTOR, "h4").text Here driver is the webdriver object. The find_element() method identifies the element using the specified locator, and the text property extracts the text content. Modern Selenium Approach Recent Selenium versions use the By class for locators instead of the deprecated find_element_by_* methods ? from selenium import webdriver from selenium.webdriver.common.by import ...
Read MoreHow to set Selenium Python WebDriver default timeout?
Setting default timeout in Selenium Python WebDriver helps prevent tests from hanging indefinitely. Selenium provides two main approaches: set_page_load_timeout() for page loading and implicitly_wait() for element location. Page Load Timeout The set_page_load_timeout() method sets a timeout for page loading. If the page doesn't load within the specified time, a TimeoutException is thrown. Syntax driver.set_page_load_timeout(timeout_in_seconds) Example from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.common.exceptions import TimeoutException # Setup WebDriver service = Service() driver = webdriver.Chrome(service=service) try: # Set page load timeout to 10 seconds ...
Read MoreWait until page is loaded with Selenium WebDriver for Python.
We can wait until the page is loaded with Selenium WebDriver using synchronization concepts. Selenium provides implicit and explicit wait mechanisms. To wait until the page is loaded, we use the explicit wait approach. The explicit wait depends on expected conditions for particular element behaviors. For waiting until the page loads, we use expected conditions like presence_of_element_located for a specific element. If the wait time elapses without the condition being met, a timeout error is thrown. Required Imports To implement explicit wait conditions, we need the WebDriverWait and expected_conditions classes ? from selenium import webdriver ...
Read MoreExplain JMeter installation in macOS
Apache JMeter is a popular open-source tool for performance testing and load testing of web applications. Installing JMeter on macOS is straightforward and can be accomplished by downloading the binary distribution and running it from the command line. Prerequisites Before installing JMeter, ensure that Java 8 or later is installed on your macOS system. You can verify your Java installation by running the following command in Terminal: java -version Step-by-Step Installation Step 1 − Download JMeter Navigate to the official Apache JMeter download page: https://jmeter.apache.org/download_jmeter.cgi Step 2 − ...
Read MoreHow to install Selenium WebDriver on Mac OS?
We can install Selenium WebDriver on Mac OS to automate web browsers for testing purposes. Selenium is a popular framework for web automation that supports multiple browsers including Chrome, Firefox, and Safari. We shall use Homebrew package manager along with pip for a streamlined installation process. Prerequisites Before installing Selenium WebDriver, ensure you have the following installed on your Mac − Python 3.x − Check with python3 --version Homebrew − Install from https://brew.sh/ Google Chrome browser − Download from official website Step-by-Step Installation Step 1: Install Selenium Python Package Install Selenium using ...
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 MoreMoving 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 More