Posts

Showing posts from February, 2018

Selenium - How to launch Chrome and Firefox browsers through Selenium Grid using RemoteWebDriver

Selenium - How to launch Chrome and Firefox browsers through Selenium Grid using RemoteWebDriver: What is RemoteWebDriver? In our previous post you have seen how to initialise Chrome\Firefox WebDriver in your local machine, but the limitation with that is you can launch the browser only on the machine on which you are running the code on and hence can utilise only one machine. If you wish to run automation across multiple machines in parallel you will need to host a selenium standalone server (hub) on one of the machine and register the machines (hosting the browsers) as node to this hub. Now you can run the automation pointing to the hub URL and the hub intern takes care of sending the commands to the remote machines and for this you will need a RemoteWebDriver. In short, RemoteWebDriver implements the WebDriver interface and is used to run automation on a remote machine. The RemoteWebDriver has two parts, a server and a client. The RemoteWebDriver server listen on a particu...

Selenium - How to initialize Chrome and Firefox WebDriver

Selenium - How to initialize Chrome and Firefox WebDriver: What is WebDriver: Its important we understand what is WebDriver, before jumping to use it to initialize the browsers. WebDriver API was introduced with Selenium 2.0 and was the primary feature of it. WebDriver is designed to provide a simpler, more concise programming interface, overcome the limitations of Selenium RC (such as Single Host origin policy) and provide better support for modern advanced web applications. It was developed to better support dynamic web pages where elements of a page may change without the page itself being reloaded.  The way Selenium RC worked was injecting javascript functions into the browser when the browser was loaded and then used its javascript to execute the commands in the browser. WebDriver makes direct calls to the browser and drives the browser directly using the browser’s built in support for automation One of the most common interview question is whethe...

Setup Selenium Hub as a Service in Ubuntu 14.04

Image
Setup Selenium Hub as a Service in Ubuntu 14.04: If you have moved to Ubuntu 16.04, kindly refer to this  link .   Setting up selenium hub as a service saves you from the tedious task of running long commands to start and restart the selenium server several times during your development. Also, this ensures that you grid is always up and running and you don't have to bring it back up every time your machine\automation server gets rebooted. Run the below command to create selenium server config file. Enter your password if asked.  sudo nano /etc/init/selenium.conf Paste the below content in this config file.  description     "run Selenium Server as hub" start on runlevel [2345] stop on runlevel [!2345] respawn exec java -jar /opt/softwares/selenium-server.jar -role hub -port 4444 Press Ctrl+X followed by Y and Enter to confirm saving the changes to the file Now create a symbolic link of this config file at destination /etc/ini...

Setup Selenium Hub as a Service in Ubuntu 16.04

Image
Setup Selenium Hub as a Service in Ubuntu 16.04: If you are still on Ubuntu 14.04, kindly refer to this link . Setting up selenium hub as a service saves you from the tedious task of running long commands to start and restart the selenium server several times during your development. Also, this ensures that you grid is always up and running and you don't have to bring it back up every time your machine\automation server gets rebooted. Run the below command to create selenium service file. Enter your password if asked.  sudo nano /etc/systemd/system/selenium.service Paste the below content in this config file.  [Unit] Description=run Selenium Server as hub [Service] ExecStart=/usr/bin/java -jar /opt/softwares/selenium-server.jar -role hub -port 4444 [Install] WantedBy=multi-user.target Press Ctrl+X followed by Y and Enter to confirm saving the changes to the file Now reload the systemd process so that it can reference to the new file you created ...

Launching Selenium Grid and Registering a Web Node

Image
Launching Selenium Grid: Download the latest version of Selenium Standalone Server from here . Open command prompt and cd to the path where you downloaded the selenium server jar file from Step 1. Ex. " cd ~/Downloads " Next we need to run the below command to start the selenium hub   (replace selenium-server-standalone-3.9.0.jar with the latest selenium server file name you downloaded) java -jar selenium-server-standalone-3.9.0.jar -role hub -port 4444 Check for the success message " Selenium Grid hub is up and running " in the console Open browser and navigate to " http://localhost:4444/grid/console " to check if the grid is up and running. Tips: Instead of doing cd to the selenium server file location and then running the command we can directly run the command by giving the absolute path of the selenium server jar file in the command java -jar /home/nishant/Downloads/selenium-server-standalone-3.9.0.jar -role hub...