Explore Courses
Liverpool Business SchoolLiverpool Business SchoolMBA by Liverpool Business School
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA (Master of Business Administration)
  • 15 Months
Popular
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Business Administration (MBA)
  • 12 Months
New
Birla Institute of Management Technology Birla Institute of Management Technology Post Graduate Diploma in Management (BIMTECH)
  • 24 Months
Liverpool John Moores UniversityLiverpool John Moores UniversityMS in Data Science
  • 18 Months
Popular
IIIT BangaloreIIIT BangalorePost Graduate Programme in Data Science & AI (Executive)
  • 12 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
upGradupGradData Science Bootcamp with AI
  • 6 Months
New
University of MarylandIIIT BangalorePost Graduate Certificate in Data Science & AI (Executive)
  • 8-8.5 Months
upGradupGradData Science Bootcamp with AI
  • 6 months
Popular
upGrad KnowledgeHutupGrad KnowledgeHutData Engineer Bootcamp
  • Self-Paced
upGradupGradCertificate Course in Business Analytics & Consulting in association with PwC India
  • 06 Months
OP Jindal Global UniversityOP Jindal Global UniversityMaster of Design in User Experience Design
  • 12 Months
Popular
WoolfWoolfMaster of Science in Computer Science
  • 18 Months
New
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Rushford, GenevaRushford Business SchoolDBA Doctorate in Technology (Computer Science)
  • 36 Months
IIIT BangaloreIIIT BangaloreCloud Computing and DevOps Program (Executive)
  • 8 Months
New
upGrad KnowledgeHutupGrad KnowledgeHutAWS Solutions Architect Certification
  • 32 Hours
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Popular
upGradupGradUI/UX Bootcamp
  • 3 Months
upGradupGradCloud Computing Bootcamp
  • 7.5 Months
Golden Gate University Golden Gate University Doctor of Business Administration in Digital Leadership
  • 36 Months
New
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Golden Gate University Golden Gate University Doctor of Business Administration (DBA)
  • 36 Months
Bestseller
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDoctorate of Business Administration (DBA)
  • 36 Months
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (DBA)
  • 36 Months
KnowledgeHut upGradKnowledgeHut upGradSAFe® 6.0 Certified ScrumMaster (SSM) Training
  • Self-Paced
KnowledgeHut upGradKnowledgeHut upGradPMP® certification
  • Self-Paced
IIM KozhikodeIIM KozhikodeProfessional Certification in HR Management and Analytics
  • 6 Months
Bestseller
Duke CEDuke CEPost Graduate Certificate in Product Management
  • 4-8 Months
Bestseller
upGrad KnowledgeHutupGrad KnowledgeHutLeading SAFe® 6.0 Certification
  • 16 Hours
Popular
upGrad KnowledgeHutupGrad KnowledgeHutCertified ScrumMaster®(CSM) Training
  • 16 Hours
Bestseller
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 4 Months
upGrad KnowledgeHutupGrad KnowledgeHutSAFe® 6.0 POPM Certification
  • 16 Hours
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Science in Artificial Intelligence and Data Science
  • 12 Months
Bestseller
Liverpool John Moores University Liverpool John Moores University MS in Machine Learning & AI
  • 18 Months
Popular
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
IIIT BangaloreIIIT BangaloreExecutive Post Graduate Programme in Machine Learning & AI
  • 13 Months
Bestseller
IIITBIIITBExecutive Program in Generative AI for Leaders
  • 4 Months
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
IIIT BangaloreIIIT BangalorePost Graduate Certificate in Machine Learning & Deep Learning (Executive)
  • 8 Months
Bestseller
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Liverpool Business SchoolLiverpool Business SchoolMBA with Marketing Concentration
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA with Marketing Concentration
  • 15 Months
Popular
MICAMICAAdvanced Certificate in Digital Marketing and Communication
  • 6 Months
Bestseller
MICAMICAAdvanced Certificate in Brand Communication Management
  • 5 Months
Popular
upGradupGradDigital Marketing Accelerator Program
  • 05 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Corporate & Financial Law
  • 12 Months
Bestseller
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in AI and Emerging Technologies (Blended Learning Program)
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Intellectual Property & Technology Law
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Dispute Resolution
  • 12 Months
upGradupGradContract Law Certificate Program
  • Self paced
New
ESGCI, ParisESGCI, ParisDoctorate of Business Administration (DBA) from ESGCI, Paris
  • 36 Months
Golden Gate University Golden Gate University Doctor of Business Administration From Golden Gate University, San Francisco
  • 36 Months
Rushford Business SchoolRushford Business SchoolDoctor of Business Administration from Rushford Business School, Switzerland)
  • 36 Months
Edgewood CollegeEdgewood CollegeDoctorate of Business Administration from Edgewood College
  • 24 Months
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with Concentration in Generative AI
  • 36 Months
Golden Gate University Golden Gate University DBA in Digital Leadership from Golden Gate University, San Francisco
  • 36 Months
Liverpool Business SchoolLiverpool Business SchoolMBA by Liverpool Business School
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA (Master of Business Administration)
  • 15 Months
Popular
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Business Administration (MBA)
  • 12 Months
New
Deakin Business School and Institute of Management Technology, GhaziabadDeakin Business School and IMT, GhaziabadMBA (Master of Business Administration)
  • 12 Months
Liverpool John Moores UniversityLiverpool John Moores UniversityMS in Data Science
  • 18 Months
Bestseller
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Science in Artificial Intelligence and Data Science
  • 12 Months
Bestseller
IIIT BangaloreIIIT BangalorePost Graduate Programme in Data Science (Executive)
  • 12 Months
Bestseller
O.P.Jindal Global UniversityO.P.Jindal Global UniversityO.P.Jindal Global University
  • 12 Months
WoolfWoolfMaster of Science in Computer Science
  • 18 Months
New
Liverpool John Moores University Liverpool John Moores University MS in Machine Learning & AI
  • 18 Months
Popular
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (AI/ML)
  • 36 Months
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDBA Specialisation in AI & ML
  • 36 Months
Golden Gate University Golden Gate University Doctor of Business Administration (DBA)
  • 36 Months
Bestseller
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDoctorate of Business Administration (DBA)
  • 36 Months
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (DBA)
  • 36 Months
Liverpool Business SchoolLiverpool Business SchoolMBA with Marketing Concentration
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA with Marketing Concentration
  • 15 Months
Popular
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Corporate & Financial Law
  • 12 Months
Bestseller
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Intellectual Property & Technology Law
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Dispute Resolution
  • 12 Months
IIITBIIITBExecutive Program in Generative AI for Leaders
  • 4 Months
New
IIIT BangaloreIIIT BangaloreExecutive Post Graduate Programme in Machine Learning & AI
  • 13 Months
Bestseller
upGradupGradData Science Bootcamp with AI
  • 6 Months
New
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
KnowledgeHut upGradKnowledgeHut upGradSAFe® 6.0 Certified ScrumMaster (SSM) Training
  • Self-Paced
upGrad KnowledgeHutupGrad KnowledgeHutCertified ScrumMaster®(CSM) Training
  • 16 Hours
upGrad KnowledgeHutupGrad KnowledgeHutLeading SAFe® 6.0 Certification
  • 16 Hours
KnowledgeHut upGradKnowledgeHut upGradPMP® certification
  • Self-Paced
upGrad KnowledgeHutupGrad KnowledgeHutAWS Solutions Architect Certification
  • 32 Hours
upGrad KnowledgeHutupGrad KnowledgeHutAzure Administrator Certification (AZ-104)
  • 24 Hours
KnowledgeHut upGradKnowledgeHut upGradAWS Cloud Practioner Essentials Certification
  • 1 Week
KnowledgeHut upGradKnowledgeHut upGradAzure Data Engineering Training (DP-203)
  • 1 Week
MICAMICAAdvanced Certificate in Digital Marketing and Communication
  • 6 Months
Bestseller
MICAMICAAdvanced Certificate in Brand Communication Management
  • 5 Months
Popular
IIM KozhikodeIIM KozhikodeProfessional Certification in HR Management and Analytics
  • 6 Months
Bestseller
Duke CEDuke CEPost Graduate Certificate in Product Management
  • 4-8 Months
Bestseller
Loyola Institute of Business Administration (LIBA)Loyola Institute of Business Administration (LIBA)Executive PG Programme in Human Resource Management
  • 11 Months
Popular
Goa Institute of ManagementGoa Institute of ManagementExecutive PG Program in Healthcare Management
  • 11 Months
IMT GhaziabadIMT GhaziabadAdvanced General Management Program
  • 11 Months
Golden Gate UniversityGolden Gate UniversityProfessional Certificate in Global Business Management
  • 6-8 Months
upGradupGradContract Law Certificate Program
  • Self paced
New
IU, GermanyIU, GermanyMaster of Business Administration (90 ECTS)
  • 18 Months
Bestseller
IU, GermanyIU, GermanyMaster in International Management (120 ECTS)
  • 24 Months
Popular
IU, GermanyIU, GermanyB.Sc. Computer Science (180 ECTS)
  • 36 Months
Clark UniversityClark UniversityMaster of Business Administration
  • 23 Months
New
Golden Gate UniversityGolden Gate UniversityMaster of Business Administration
  • 20 Months
Clark University, USClark University, USMS in Project Management
  • 20 Months
New
Edgewood CollegeEdgewood CollegeMaster of Business Administration
  • 23 Months
The American Business SchoolThe American Business SchoolMBA with specialization
  • 23 Months
New
Aivancity ParisAivancity ParisMSc Artificial Intelligence Engineering
  • 24 Months
Aivancity ParisAivancity ParisMSc Data Engineering
  • 24 Months
The American Business SchoolThe American Business SchoolMBA with specialization
  • 23 Months
New
Aivancity ParisAivancity ParisMSc Artificial Intelligence Engineering
  • 24 Months
Aivancity ParisAivancity ParisMSc Data Engineering
  • 24 Months
upGradupGradData Science Bootcamp with AI
  • 6 Months
Popular
upGrad KnowledgeHutupGrad KnowledgeHutData Engineer Bootcamp
  • Self-Paced
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Bestseller
KnowledgeHut upGradKnowledgeHut upGradBackend Development Bootcamp
  • Self-Paced
upGradupGradUI/UX Bootcamp
  • 3 Months
upGradupGradCloud Computing Bootcamp
  • 7.5 Months
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 5 Months
upGrad KnowledgeHutupGrad KnowledgeHutSAFe® 6.0 POPM Certification
  • 16 Hours
upGradupGradDigital Marketing Accelerator Program
  • 05 Months
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
upGradupGradData Science Bootcamp with AI
  • 6 Months
Popular
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Bestseller
upGradupGradUI/UX Bootcamp
  • 3 Months
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 4 Months
upGradupGradCertificate Course in Business Analytics & Consulting in association with PwC India
  • 06 Months
upGradupGradDigital Marketing Accelerator Program
  • 05 Months

Selenium Projects with Eclipse Samples in 2024

Updated on 11 July, 2024

44.37K+ views
10 min read

Selenium is among the prominent technologies in the automation section of web testing. By using Selenium properly, you can make your testing process quite efficient and complete multiple tasks within a small amount of time. 

That’s why learning Selenium has gained a lot of significance. In this article, you’ll learn how to work on a Selenium project with Eclipse, another popular technology for Java-based projects. 

First, I’ll discuss the basics of these technologies. Then we’ll look at how you can start a Selenium project by using Eclipse. We have also shared a few sample selenium projects which you can take inspiration from. Let’s get started. 

Check out our free courses to get an edge over the competition.

What is Selenium?

Selenium is a portable framework and a popular tool for web app testing. It is compatible with multiple programming languages such as Python, C#, and Java. You can use those languages to perform various tasks with Selenium, such as creating a test script. Still, most users prefer to use Java with this framework because it’s more user-friendly than the rest. 

Selenium is not a single software application. It is a suite of various tools that you can use to perform different sorts of testing. 

Check out upGrad’s Full Stack Development Bootcamp

Selenium has the following tools in its suite:

  • Selenium IDE (Integrated Development Environment)
  • Selenium WebDriver
  • Selenium Client API
  • Selenium Remote Control (Deprecated)
  • Selenium Grid

Jason Huggins created Selenium in the year 2004. He wanted to automate the repetitive manual testing process, so he made a JavaScript program. That same program became the Selenium Core. Apart from Jason, many other developers contributed to creating the Selenium suite.

Check out upGrad’s Advanced Certification in DevOps 

Why it’s called Selenium?

Selenium derives its name from a joke. At the time of its development, there was another major automated testing framework named Mercury Interactive. Jason jokingly suggested the Selenium to his friends because Selenium is a popular antidote for Mercury poisoning. His friends accepted the suggestion and gave it the name it has now. 

Features of Selenium

Selenium has many features; the most prominent ones are the following:

  • Selenium is compatible with almost all major browsers of the industry, including Chrome, Opera, Safari, etc.
  • This suite has a specific group of commands which are called Selenese. They hold the sequence of every Selenium command.
  • You can locate elements on a web page through Selenium’s element locators. 
  • You cannot use Selenium to test desktop applications or mobile apps. You can only use it for web app testing. 

Read: Selenium Project Ideas

What is Maven?

Maven is an automation tool that developers mostly use for Java projects. Apart from Java, you can use it with several other programming languages such as C#, Scala, Ruby, etc. It’s a product of the Apache Software Foundation, so it is an open-source tool. 

Maven makes the build process much more straightforward and provides you with a uniform build system. It ensures that Java developers follow the best development sample selenium projects for practice while working on Java projects. It entered the industry in the year 2002, and since then, it has become one of the most significant Apache projects. 

Maven derives its name from the Yiddish word ‘maven,’ which means “accumulator of knowledge.” 

Features of Maven

  • Maven ensures consistency among various projects
  • It simplifies project set up by providing the boilerplate for modules or projects
  • Can work with several projects at once
  • Maven can build any quantity of projects into its specific output types such as a WAR or JAR without requiring scripting in many cases
  • It is based on the POM (project object model)

Now that we have discussed Selenium and Maven let’s understand the Eclipse IDE. Having a working knowledge of these three is crucial if you want to work on a Selenium project with Eclipse.

upGrad’s Exclusive Software and Tech Webinar for you –

SAAS Business – What is So Different?

What is the Eclipse IDE?

Eclipse is an IDE (integrated development environment) that helps developers work with Selenium and related technologies. You can use Eclipse to develop applications in C++, Ruby, Python, C, Perl, Java, etc. 

Features of the Eclipse IDE

  • It is an open-source tool, which means you can use it for free.
  • The foundational platform of the Eclipse IDE has multiple plugins and can be extended with more plugins. 
  • You can convert Eclipse into an IDE for any programming language by using its respective plugin.
  • The JDT (Java Development Tools) project gives a plugin to use Eclipse as a Java IDE. Similarly, PyDev is a plugin that allows you to use Eclipse as a Python IDE.
  • You can use the Eclipse platform and its plugins to create IDEs, client applications, etc. 

How to Create a Selenium Project with Eclipse IDE

In this section of our article, we’ll look at how you can create a Selenium project with Eclipse. It’s the first step of working on a sample selenium project in eclipse, and many beginners struggle with it.

You’d need to have Maven and TestNG installed in your system before you can create a Selenium project through Eclipse. Ensure that you install them (Maven and TestNG) before you begin this process.

Step #1:

Open Eclipse and right-click on the Package Explorer section. You’d see a menu pop-up. Select the ‘New’ button, which will open another menu to select the “Other…” option.  

Step #2: 

When you’d click the “Other…” button, it would open a new window. Select the Maven Project and then click on the ‘Next’ button. 

Step #3: 

A new window will appear now. Here, you have to tick the ‘Create a simple project (skip archetype selection)” box. After that, select the “Next” button. 

Step #4: 

In this section, you’d have to enter the Group Id and the Artifact Id. They both are vital for the naming of your project. The Group Id will help you identify your project across all the other ones. It must follow the package name rules. This means it should start with a reverse domain name you control. Maven doesn’t enforce this naming rule; however, due to the tool’s vast popularity, it has become a common practice to follow this rule. You can make multiple subgroups with a Group Id as well. 

The Artifact Id is the name of your jar without a version. If you are its creator, you can choose any name you want as long as you don’t use any strange symbols and only use lowercase letters.  

Keep the above points in mind while entering the Group Id and Artifact Id for your project. Once you have entered these details, click on the “Finish” button.

Step #5:

Let’s add the necessary dependencies to the POM file for our project. Head to the pom.xml file and select the ‘pom.xml’ tab in Eclipse. Now, add the dependencies related to TestNG and Selenium WebDriver.

Step #6: 

In this step, get a testng.xml file by creating a TestNG class. Copy the following code in this file:

package tests;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
public class NewTest {
public WebDriver driver;
  @Test
  public void openMyBlog() {
driver.get("https://www.softwaretestingmaterial.com/");
  }
  @BeforeClass
  public void beforeClass() {
System.setProperty("webdriver.gecko.driver", "D:\\Selenium\\Drivers\\geckodriver.exe");
driver = new FirefoxDriver();
  }
  @AfterClass
  public void afterClass() {
driver.quit();
  }
}

Step #7: 

Now you can run your Selenium project with Eclipse by using the TestNG file. 

Make sure that you understand the above tutorial before you move onto the next one. That’s because, in the following section, we’ll discuss a working of a Selenium Java project example that you can build by using Eclipse.

Also Read: Selenium Developer Salary in India

Get Software Development Course from the World’s top Universities. Earn Executive PG Programs, Advanced Certificate Programs, or Masters Programs to fast-track your career.

Selenium Project with Eclipse: An Example

Here, we have shared the code for a flight-booking solution based on Selenium. The software selects the arrival and departure locations for the flight along with the date of the same. This tool performs these tasks on the MakeMyTrip website. 

You can take inspiration from these sample selenium projects to create a similar Selenium project with Eclipse yourself. If you haven’t worked on a Selenium project before, we suggest working on a smaller version of this project first.

For example, you can create a program that selects the arrival and departure locations only. On the other hand, if you want to expand on this project, you can add more functionalities. 

The Browser

package browser;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class BrowserSelection 
{
static WebDriver driver;
public static WebDriver UsingChrome()
{
System.setProperty("webdriver.chrome.driver", "E:\\SeleniumLibs\\\\chromedriver_win32\\chromedriver.exe");
driver = new ChromeDriver();
driver.manage().window().maximize();
return driver;
}
}

The Code

package makemytrip;
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import browser.BrowserSelection;
public class MakeMyTripProject 
{
WebDriver driver;
@BeforeMethod
public void OpenBrowser()
{
driver = BrowserSelection.UsingChrome();
}
@Test
public void TripDetails() throws InterruptedException, AWTException
{
driver.get("https://www.makemytrip.com/");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
Thread.sleep(5000);
try
{
/*String frameStatus = driver.findElement(By.id("webklipper-publisher-widget-container-notification-frame")).getTagName();
System.out.println(frameStatus);
driver.switchTo().frame("notification-frame-31764456");
driver.findElement(By.xpath(".//*[@id='webklipper-publisher-widget-container-notification-close-div']/i")).click();
driver.switchTo().defaultContent();
Thread.sleep(3000); */
driver.findElement(By.xpath("//input[@id='hp-widget__sfrom']")).click();
driver.findElement(By.xpath("//input[@id='hp-widget__sfrom']")).clear();
//driver.findElement(By.xpath("//input[@id='hp-widget__sfrom']")).sendKeys("Goa");
Thread.sleep(2000);
List<WebElement> fromCities = driver.findElements(By.xpath("//ul[@id='ui-id-1']/li/div/p/span[1]"));
System.out.println(fromCities.size()+"\n");
for(int i=0;i<fromCities.size();i++)
{
WebElement element=fromCities.get(i);
System.out.println(element.getAttribute("innerHTML"));
}
//driver.findElement(By.xpath("//ul[@id='ui-id-1']/li/div/p/span")).click();
driver.findElement(By.xpath("//li[contains(@aria-label,'Top Cities : Goa, India ')]/div/p/span[1]")).click();
driver.findElement(By.xpath("//input[@id='hp-widget__sTo']")).click();
driver.findElement(By.xpath("//input[@id='hp-widget__sTo']")).clear();
//driver.findElement(By.xpath("//input[@id='hp-widget__sTo']")).sendKeys("Mumbai");
Thread.sleep(2000);
List<WebElement> toCities = driver.findElements(By.xpath("//ul[@id='ui-id-2']/li/div/p/span[1]"));
System.out.println(toCities.size()+"\n");
for(int i=0;i<toCities.size();i++)
{
WebElement element=toCities.get(i);
System.out.println(element.getAttribute("innerHTML"));
}
//driver.findElement(By.xpath("//ul[@id='ui-id-2']/li/div/p/span")).click();
driver.findElement(By.xpath("//ul[@id='ui-id-2']/li[3]/div/p/span[1]")).click();
Thread.sleep(2000);
driver.findElement(By.xpath("//input[@id='hp-widget__depart']")).click();
Thread.sleep(2000);
String date = "10-OCTOBER-2018";
String splitter[] = date.split("-");
String month_year = splitter[1];
String day = splitter[0];
System.out.println(month_year);
System.out.println(day);
selectDate(month_year,day);
Thread.sleep(3000);
driver.findElement(By.xpath("//button[@id='searchBtn']")).click();
Thread.sleep(5000);
Thread.sleep(2000);
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("window.scrollBy(0,3000)");
/*Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_PAGE_DOWN);
robot.keyRelease(KeyEvent.VK_PAGE_DOWN);*/
Thread.sleep(5000);
driver.findElement(By.xpath("//div[@id='aln_AI_dep']/span[3]")).click();
Thread.sleep(5000);
List<WebElement> flights = driver.findElements(By.xpath("//div[@class='top_first_part clearfix']/div/span/span[2]/span[1]"));
System.out.println("No. of Air India flight search results: ---"+flights.size());
}catch(WebDriverException e)
{
System.out.println("Exception is: ---"+e+"\n");
}
}
public void selectDate(String monthyear, String Selectday) throws InterruptedException
{
List<WebElement> elements = driver.findElements(By.xpath("//div[@class='ui-datepicker-title']/span[1]"));
for (int i=0; i<elements.size();i++)
{
System.out.println(elements.get(i).getText());
//Selecting the month
if(elements.get(i).getText().equals(monthyear))
{
//Selecting the date
List<WebElement> days = driver.findElements(By.xpath("//div[@class='ui-datepicker-inline ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-datepicker-multi ui-datepicker-multi-2']/div[2]/table/tbody/tr/td/a"));
for (WebElement d:days)
{
System.out.println(d.getText());
if(d.getText().equals(Selectday))
{
d.click();
Thread.sleep(10000);
return;
}
}
}
}
driver.findElement(By.xpath("//div[@class='ui-datepicker-inline ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-datepicker-multi ui-datepicker-multi-2']/div[2]/div/a/span")).click();
selectDate(monthyear,Selectday);
}
@AfterMethod
public void CloseBrowser()
{
driver.quit();
}
}

Sample Selenium Project with Source Code: Selenium Test Automation With Eclipse

Read: 5 Interesting Selenium Project Ideas & Topics For Beginners

Learn to Create a Selenium Project with Eclipse and More

Selenium is quite a vital technology. Learning about it will help you become a proficient software testing professional. Here are some additional resources on Selenium and Maven for your further reading:

If you want to learn more about Selenium or software testing, we recommend taking a computer science course. You’ll get to know from industry experts through interactive quizzes, problems, and projects. Exploring sample selenium projects can be an excellent way to enhance your practical understanding.

We hope you found this guide useful. If you have any questions regarding this article or Selenium, please ask us through the comment section below. We’d love to hear from you.

If you’re interested to learn more about full-stack software development, check out upGrad & IIIT-B’s Executive PG Program in Full-stack Software Development which is designed for working professionals and offers 500+ hours of rigorous training, 9+ projects, and assignments, IIIT-B Alumni status, practical hands-on capstone projects & job assistance with top firms.

Frequently Asked Questions (FAQs)

1. Does Selenium provide good career opportunities?

Indulging in this open-source and easy-to-use technology definitely holds a prosperous career since there will be a constant demand for software in most firms in the near future. Selenium is used widely for testing by several MNCs, including Facebook, Microsoft, Cognizant, HP, Accenture, etc. These companies hire Selenium Testers that are well-versed in the language and have received Selenium certification. Thus, Selenium provides decent career opportunities and can be a great career choice.

2. Is it hard to learn Selenium?

Learning Selenium is not that difficult, but it needs solid discipline and a brilliant road map to master it quickly. If you have some experience in programming, Selenium would not be very hard to grasp. To study automated testing with Selenium in an organized and effective manner, one should focus on learning 4 things: Java, Selenium Webdriver, TestNG, and Frameworks. Thus, you can learn Selenium with good strategy and consistency along with a clear plan; it is no rocket science.

3. How much does a Selenium tester earn in India?

A selenium tester's income is determined by the firm he works for, the number of years he has worked in the field, and his skill set. In the automated testing industry, skill sets and experience are the most important since they determine the difference in work wage between individuals, even within the same organization. The income of a Selenium Automation Tester in India ranges from 4.0 lakhs to 15.1 lakhs per year, with an average yearly salary of 7.4 lakhs.

RELATED PROGRAMS