1.
Install JAVA:
1.search in the google like jdk download.
there you download the jdk software which specifies longer term support.
install x64 msi installer
2.set the enviornment variables:
in the search box-->edit system enviornment var1.iables-->click on enviornment
variable
1.JAVA_HOME=C:\Program Files\Java\jdk-212.then takr the bin path and set it in the
system path of enviornment variables tab
2.then takr the bin path and set it in the system path of enviornment variables
tab
bin path of local =C:\Program Files\Java\jdk-21\bin
3.after setting system enviorment variables, goto command prompt and enter java -
version to check java is installed or not
-----------------------------------------------------------------------------------
----------------------------------------------
2.Install eclipse:
1.search in the google like eclipse download
click on the packages-->click on eclipse IDE for java developers
2.create one java project-->while creating java project-->uncheck module-info.java
3.convert the created java project into maven project.-->update the selenium -java
dependecy in the pom.xml and click on project
and select build automatically
4. Dependencies required:
1.selenium-java
2.TestNG
5.steps while selenium jars are not updating:
Specifically in my case, the following sequence of actions worked:
Project -> uncheck Build Automatically
[accept incoming changes] if applies
Project -> clean
Run -> Run As -> Maven clean
Run -> Run As -> Maven install
Project -> check build automatically
if errors on Problems Tab appear:
select all projects, Refresh F5
if still errors:
delete errors manually on Problems Tab (it might be that Eclipse has not updated
the dependencies, etc.)
select all projects, Refresh F5
5.goto project-->then update maven project-->u will see the selenium jars
-----------------------------------------------------------------------------------
-------------------------------------------
3.Understanding core concepts of browser driver classes and web driver interface:
1.how we are invoiking the drivers:
chromedriver driver= new chrome driver
if you are automating it in the chrome browser means we will call chrome driver.
this chromedriver will have its own classes
and methods. these classes and methods are not applicable to firefox, internet
explorer, etc.
firefox driver= new firefox driver
now if you are automating it in the firefox browser means we will call firefox
driver. this firefoxdriver will have its own classes
and methods. these classes and methods are not applicable to chrome, internet
explorer, etc.
hence to avoid this problem, selenium has introduced webdriver. this webdriver
will have its own class and methods.
these methods and classes will be applicable to all the browsers.
Webdriver is an interface.
how we are calling webdriver
Webdriver driver= new chromedriver();
2.chromedriver.exe acts like an agent.
first your selenium code communicates with chromerdriver.exe and then from
chromedriver.exe will communicate with chromebrowser.
your selenium code will not directly communicate with browsers. it will
communicate with chromedriver.exe file , then with browseers
3. take the chrome version from google chrome:Version 133.0.6943.59 (Official
Build) (64-bit)
download chromedriver with same version of google chrome
Version 133.0.6943.99 (Official Build) (64-bit)
give the path of chromedriver.
C:\chromedriver\chromedriver-win64\chromedriver-win64
C:/chromedriver/chromedriver-win64/chromedriver-win64/chromedriver.exe
System.setProperty("webdriver.chrome.driver","C:/chromedriver/chromedriver-
win64/chromedriver-win64/chromedriver.exe");
WebDriver driver= new ChromeDriver();
-----------------------------------------------------------------------------------
--------------------------------------------
4.Getting started with basics of selenium webriver:
Dependecies required are:
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.23.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.10.2</version>
<scope>test</scope>
</dependency>
-----------------------------------------------------------------------------------
--------------------------------------------
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class SellIntroduction {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver",
"C:/chromedriver/chromedriver-win64/chromedriver-win64/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://rahulshettyacademy.com/");
System.out.println("title"+driver.getTitle());
System.out.println("current url"+driver.getCurrentUrl());
//driver.close();
driver.quit();
Here, difference between driver.close() and driver.quit() is that, driver.close()
closes the current window.
wehre as driver.quit() closes the current window and also the other window also.
-----------------------------------------------------------------------------------
------------------------------------------------
5.How to run the test in firefox browser with gecko driver:
download the gecko driver.exe file and run the same below code
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class SellIntroduction {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "path of gecko driver");
WebDriver driver = new FirefoxDriver();
driver.get("https://rahulshettyacademy.com/");
System.out.println("title"+driver.getTitle());
System.out.println("current url"+driver.getCurrentUrl());
//driver.close();
driver.quit();
-----------------------------------------------------------------------------------
----------------------------------------------
6.How to run the test in microsoft edge browser
downlod the edge driver according to the microsoft edge browser version and run the
same below code
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class SellIntroduction {
public static void main(String[] args) {
System.setProperty("webdriver.edge.driver", "path to microsoft edge
driver ");
WebDriver driver = new EdgeDriver();
driver.get("https://rahulshettyacademy.com/");
System.out.println("title"+driver.getTitle());
System.out.println("current url"+driver.getCurrentUrl());
//driver.close();
driver.quit();
}
-----------------------------------------------------------------------------------
----------------------------------------------