SlideShare a Scribd company logo
1 of 12
Selenium WebDriver useful commands
Kadarkarai Selvam
Browser Commands
driver.get(URL);
❖ Opens the browser and paste the URL. And wait for the URL to load
driver.getTitle();
❖ Fetches the Title of the current web page
driver.getCurrentUrl();
❖ Fetches the current URL from the browser
Browser Memory Allocation
driver= new ChromeDriver();
❖ Creates the browser instance object and allocates the memory
driver.close();
❖ Terminates the current browser window
driver.quit();
❖ Terminates all the browser window including the tabs if opened
Browser Navigation
driver.navigate().to(“”)
❖ Navigate to a url defined same as get. But it will not wait for the page to load
driver.navigate().back(“”)
❖ It acts as if a user click on back button in the browser
driver.navigate().forward(“”)
❖ It acts as if a user click on forward button in the browser
driver.navigate().refresh()
❖ It acts as if a user click on reload button in the browser
Get values
getText()
getAttribute(“aria-label”)
Verification statement
isDisplayed()
❖ Used to verify presence of a web element and returns pass or fail
isSelected()
❖ Used to verify whether the web element is selected or not. It is generally used
for checkbox and radio button verification
isEnabled()
❖ Used to verify whether the webElement is editable or not
Assert
❖ This command is the verification step in a test case
❖ I.e,. Expected and Actual Result will be verified in this Assert statements
❖ Two types are assertion
➢ Hard Assert
➢ Soft Assert
Hard Assert
❖ Verify when the test case is failed or not
❖ HardAssert will stop the execution when there is a failure
➢ AssertEquals
➢ AssertNotEquals
➢ AssertTrue
➢ AssertFalse
➢ AssertNull
➢ AssertNotNull
Hard Assert example
Assert.AssertFalse(condition);
This Assert will pass if condition is false
Assert.AssertTrue(condition);
This Assert will pass if condition is true
Assert.assertEquals(actual,expected);
This Assert will pass if both the actual and expected are same
Assert.assertNotEquals(actual,expected);
This Assert will pass if both the actual and expected are different
SoftAssert
Soft Assert will continue the execution of test case even if the test case is failed
With SoftAssert, We can check for multiple assertion in a single method or test
case
SoftAssert sa = new SoftAssert();
assertEquals : This method is used to verify the values are same or
not
assertNotEquals : Used to verify the values are different or not
SoftAssert
❖ Here the two values to verify can be of any datatype such as String, Float, int ,etc
❖ SoftAssert can also make the statement as fail using command
sa.fail();
❖ For SoftAssert, once all the assertion is added, it requires assertAll() to make
the test cases are pass or fail depending upon each assert statements
❖ In All Assert statements, we can provide a “Message” about the verification
sa.assertEquals("From UI","From addition","Verify whether
addition of values is true");
Thank you
For any Assistance
kadarkarai@live.com
+91-9578921178

More Related Content

Similar to Selenium web driver useful commands

Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoft
ch samaram
 

Similar to Selenium web driver useful commands (20)

Testing And Mxunit In ColdFusion
Testing And Mxunit In ColdFusionTesting And Mxunit In ColdFusion
Testing And Mxunit In ColdFusion
 
Understanding JavaScript Testing
Understanding JavaScript TestingUnderstanding JavaScript Testing
Understanding JavaScript Testing
 
Angular JS Unit Testing - Overview
Angular JS Unit Testing - OverviewAngular JS Unit Testing - Overview
Angular JS Unit Testing - Overview
 
Automation Testing
Automation TestingAutomation Testing
Automation Testing
 
Java. Explicit and Implicit Wait. Testing Ajax Applications
Java. Explicit and Implicit Wait. Testing Ajax ApplicationsJava. Explicit and Implicit Wait. Testing Ajax Applications
Java. Explicit and Implicit Wait. Testing Ajax Applications
 
JavaScript Unit Testing with an Angular 5.x Use Case 101
JavaScript Unit Testing with an Angular 5.x Use Case 101JavaScript Unit Testing with an Angular 5.x Use Case 101
JavaScript Unit Testing with an Angular 5.x Use Case 101
 
Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoft
 
Test driven node.js
Test driven node.jsTest driven node.js
Test driven node.js
 
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentWe Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End Development
 
C++ 11 usage experience
C++ 11 usage experienceC++ 11 usage experience
C++ 11 usage experience
 
Selenium with java
Selenium with javaSelenium with java
Selenium with java
 
Developer Test - Things to Know
Developer Test - Things to KnowDeveloper Test - Things to Know
Developer Test - Things to Know
 
Soaoui
SoaouiSoaoui
Soaoui
 
Selenium Webdriver
Selenium WebdriverSelenium Webdriver
Selenium Webdriver
 
Mastering Assertions in Automation Testing, Importance and Best Practices.pdf
Mastering Assertions in Automation Testing, Importance and Best Practices.pdfMastering Assertions in Automation Testing, Importance and Best Practices.pdf
Mastering Assertions in Automation Testing, Importance and Best Practices.pdf
 
Advanced Perl Techniques
Advanced Perl TechniquesAdvanced Perl Techniques
Advanced Perl Techniques
 
Thomas Fuchs Presentation
Thomas Fuchs PresentationThomas Fuchs Presentation
Thomas Fuchs Presentation
 
RSpec 3: The new, the old, the good
RSpec 3: The new, the old, the goodRSpec 3: The new, the old, the good
RSpec 3: The new, the old, the good
 
Jasmine with JS-Test-Driver
Jasmine with JS-Test-DriverJasmine with JS-Test-Driver
Jasmine with JS-Test-Driver
 
How To Automate Cross Browser Testing
How To Automate Cross Browser TestingHow To Automate Cross Browser Testing
How To Automate Cross Browser Testing
 

More from KadarkaraiSelvam

More from KadarkaraiSelvam (11)

Java 2
Java 2Java 2
Java 2
 
Java 1
Java 1Java 1
Java 1
 
Java selenium web driver
Java selenium web driverJava selenium web driver
Java selenium web driver
 
Selenium inputs
Selenium inputsSelenium inputs
Selenium inputs
 
Selenium TestNG
Selenium TestNGSelenium TestNG
Selenium TestNG
 
Maven and versioning
Maven and versioningMaven and versioning
Maven and versioning
 
Java Inheritance and Polymorphism
Java Inheritance and PolymorphismJava Inheritance and Polymorphism
Java Inheritance and Polymorphism
 
Java Control Statements
Java Control StatementsJava Control Statements
Java Control Statements
 
Java JVM
Java JVMJava JVM
Java JVM
 
Java variables and classes
Java variables and classesJava variables and classes
Java variables and classes
 
Selenium ide 1
Selenium ide 1Selenium ide 1
Selenium ide 1
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 

Selenium web driver useful commands

  • 1. Selenium WebDriver useful commands Kadarkarai Selvam
  • 2. Browser Commands driver.get(URL); ❖ Opens the browser and paste the URL. And wait for the URL to load driver.getTitle(); ❖ Fetches the Title of the current web page driver.getCurrentUrl(); ❖ Fetches the current URL from the browser
  • 3. Browser Memory Allocation driver= new ChromeDriver(); ❖ Creates the browser instance object and allocates the memory driver.close(); ❖ Terminates the current browser window driver.quit(); ❖ Terminates all the browser window including the tabs if opened
  • 4. Browser Navigation driver.navigate().to(“”) ❖ Navigate to a url defined same as get. But it will not wait for the page to load driver.navigate().back(“”) ❖ It acts as if a user click on back button in the browser driver.navigate().forward(“”) ❖ It acts as if a user click on forward button in the browser driver.navigate().refresh() ❖ It acts as if a user click on reload button in the browser
  • 6. Verification statement isDisplayed() ❖ Used to verify presence of a web element and returns pass or fail isSelected() ❖ Used to verify whether the web element is selected or not. It is generally used for checkbox and radio button verification isEnabled() ❖ Used to verify whether the webElement is editable or not
  • 7. Assert ❖ This command is the verification step in a test case ❖ I.e,. Expected and Actual Result will be verified in this Assert statements ❖ Two types are assertion ➢ Hard Assert ➢ Soft Assert
  • 8. Hard Assert ❖ Verify when the test case is failed or not ❖ HardAssert will stop the execution when there is a failure ➢ AssertEquals ➢ AssertNotEquals ➢ AssertTrue ➢ AssertFalse ➢ AssertNull ➢ AssertNotNull
  • 9. Hard Assert example Assert.AssertFalse(condition); This Assert will pass if condition is false Assert.AssertTrue(condition); This Assert will pass if condition is true Assert.assertEquals(actual,expected); This Assert will pass if both the actual and expected are same Assert.assertNotEquals(actual,expected); This Assert will pass if both the actual and expected are different
  • 10. SoftAssert Soft Assert will continue the execution of test case even if the test case is failed With SoftAssert, We can check for multiple assertion in a single method or test case SoftAssert sa = new SoftAssert(); assertEquals : This method is used to verify the values are same or not assertNotEquals : Used to verify the values are different or not
  • 11. SoftAssert ❖ Here the two values to verify can be of any datatype such as String, Float, int ,etc ❖ SoftAssert can also make the statement as fail using command sa.fail(); ❖ For SoftAssert, once all the assertion is added, it requires assertAll() to make the test cases are pass or fail depending upon each assert statements ❖ In All Assert statements, we can provide a “Message” about the verification sa.assertEquals("From UI","From addition","Verify whether addition of values is true");
  • 12. Thank you For any Assistance kadarkarai@live.com +91-9578921178