Posts

Express Form Handling, File Upload, EJS, Redirect

Consider below HTML form. Its not mandatory to use same form, you can modify fields. What is important is, your form shall include all basic types of input fields e.g. text, password, radio, checkbox, option list, text area, etc. After this form, there are list of tasks that you should implement in same web app. <title>Form with all controls</title> <style> label { display: inline-block; width: 100px; }</style>  <h1>User Registration Form</h1> <form action="form-handler" method="POST">   <h2> Student Registration Form</h2>   <label>Name</label><input maxlength="8" name="name" size="20" type="text">   <label>Password</label> <input name="password" size="20" type="password">    <label>Subjects</label>   <input name="Algorithms" type="checkbox"> Algorithms   <input name=&

Practice JavaScript, Setup Node, NPM and Explore Some Methods of HTTP Module

Prepare code samples to demonstrate usage of following concepts in JS: Fat Arrow functions Create modules, export it and use it by importing into another module Create classes that extends another class. create its object and use it. Spread operator with usage in arrays and objects Object Destructuring Please make use of validator packages and validate different types of data using:  https://www.npmjs.com/package/validator Makeuse of different methods in string module  https://www.npmjs.com/package/@stdlib/string you an use any module from npm. searcing "string utils" Create different http handlers to perform following tasks (you can do each task in different file too): extract data received in query string and write that data to http response. For example, if user send request to a url like below: http://localhost:8000/processdata?name=ali&age=20&city=Lahore  The handler should write these data attributes on response. Send custom headers to response e.g. Content-Le

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