Posts

Reading an Excel File and Submitting a Web Form Using Selenium Java

Image
Pre-requisites: geckodriver.exe maven dependencies for apache poi & Selenium <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>4.1.1</version> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.poi/poi --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>5.2.2</version> </dependency> This automation process is divided into two parts: Reading from an Excel file  WebForm Automated Filling & Submission Reading an MS Excel File Using Apache POI: Apache POI is an open-source java library developed and distributed by Apache Software Foundation to design and modify MS Off

How to Clear Cache in Chrome Using Selenium Webdriver Java

Image
Selenium is an open-source web-based automation tool that is implemented using a web driver.  We will be using chromedriver  because Selenium 3 enables chrome driver as the custom WebDriver implementation for the Chrome browser. Pre-requisites: chromedriver.exe maven dependency selenium <dependency> <groupid>org.seleniumhq.selenium</groupid> <artifactid>selenium-java</artifactid> <version>4.1.1</version> </dependency> Steps: The following 6 steps will automate the process: Set webdriver.gecko.driver and its' path as a system property. Set the firefox diver. Typecast web driver as Javascript executor.  Browse the website. Get a clear cache button using the Javascript path. Execute the following script to execute and hit click: return document.querySelector("body > settings-ui").

How to Take a Screenshot Selenium Java

Image
Selenium is an open-source web-based automation tool that is implemented using a web driver.  We will be using geckodriver because Selenium 3 enables geckodriver as the default WebDriver implementation for Firefox. Pre-requisites: geckodriver.exe maven dependency selenium <dependency> <groupid>org.seleniumhq.selenium</groupid> <artifactid>selenium-java</artifactid> <version>4.1.1</version> </dependency> Steps: it takes 4 simple to take a screenshot: Set webdriver.gecko.driver and its' path as a system property. Set the firefox diver and browse to the website. Convert webdriver object to TakeScreenshot . Use the built-in function to get screenshot and save as file. Let’s see all the above steps in the code. We will use getScreenshotAs(OutputType>X< Target) function to take screenshot. import org.apac

How to Handle Modal Dialog Box in Selenium Webdriver Java

Image
Selenium is an open-source web-based automation tool that is implemented using a web driver.  We will be using geckodriver  because Selenium 3 enables geckodriver as the default WebDriver implementation for Firefox. Pre-requisites: geckodriver.exe maven dependency selenium <dependency> <groupid>org.seleniumhq.selenium</groupid> <artifactid>selenium-java</artifactid> <version>4.1.1</version> </dependency> Steps: It's a 4 steps process: Set webdriver.gecko.driver and its' path  as a system property. Set the firefox diver and browse to the website link. Get the accept button from dialog box as Web element using webdriver.findElement() function and CSS selector. Click the button to push the modal dialog box away. Let’s see all the above steps in the code. We will use webelement.click(

How to Select Checkbox in Selenium Webdriver Java

Image
Selenium is an open-source web-based automation tool that is implemented using a web driver.  We will be using geckodriver because Selenium 3 enables geckodriver as the default WebDriver implementation for Firefox. Pre-requisites: geckodriver.exe maven dependency selenium <dependency> <groupid>org.seleniumhq.selenium</groupid> <artifactid>selenium-java</artifactid> <version>4.1.1</version> </dependency> Steps: it's a 4 steps process: Set webdriver.gecko.driver and its' path as a system property. Set the firefox diver and browse to the website. Get all checkbox flex elements as Web elements using webdriver.findElements() function and CSS selector. Iterate over all these elements and get the desired checkbox and then hit click. Let’s see all the above steps in the code. We will use Webelment.click() fun

How to Scroll Down a Page in Selenium Webdriver Java

Image
Selenium is an open-source web-based automation tool that is implemented using a web driver.  We will be using geckodriver  because Selenium 3 enables geckodriver as the default WebDriver implementation for Firefox. Pre-requisites: geckodriver.exe maven dependency selenium <dependency> <groupid>org.seleniumhq.selenium</groupid> <artifactid>selenium-java</artifactid> <version>4.1.1</version> </dependency> Steps: it's a 6 steps process: Set webdriver.gecko.driver and its' path as a system property. Set the firefox diver. Typecast web driver as Javascript executor.  Browse the website. Set x and y coordinates for scrolling. x: Horizontal scroll  y: Vertical scroll  +ve: scroll up  -ve: scroll down Execute the script using the javascript executor. Let’s see all the abo

How to Select li Element in Selenium Java

Image
Selenium is an open-source web-based automation tool that is implemented using a web driver.  We will be using geckodriver because Selenium 3 enables geckodriver as the default WebDriver implementation for Firefox. Pre-requisites: geckodriver.exe maven dependency selenium <dependency> <groupid>org.seleniumhq.selenium</groupid> <artifactid>selenium-java</artifactid> <version>4.1.1</version> </dependency> Steps: it's a 4 steps process: Set webdriver.gecko.driver and its' path as a system property. Set the firefox diver and browse to the website. Get list items as Web elements using webdriver.findElements() function and CSS selector. Iterate over all these elements to get text and HTML. Let’s see all the above steps in the code. We will use Webelment.get