Skip to content

Tim-Cao/selenium-java-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to set up a selenium project with Java?

Prerequisite

Add a java project using gradle

  • File > New > Project > New Project

      Name: YourProjectName
      
      Location: Your project location
      
      Language: Java
      
      Build System: Gradle
      
      JDK: Your jdk
      
      Gradle DSL: Groovy
      
      Add sample code: unchecked
    

Add required dependencies

  • Add required dependencies from maven central to build.gradle

  • For example,

    implementation('junit:junit:4.13.1')
    implementation('io.github.bonigarcia:webdrivermanager:5.7.0')
    implementation('org.seleniumhq.selenium:selenium-java:4.18.1')
    
  • Load Gradle Changes

    LoadGradleChanges

Add driver classes to encapsulate selenium APIs

  • Add classes under /src/main/java/package

  • The WebDriverManager will download chromedriver automatically in runtime

    WebDriverManager.chromedriver().setup();
    

Add page object classes to wrap specific tasks

  • Add classes under /src/test/java/package

Add tests

  • Add classes under /src/test/java/package

If you would like to use example codes from this repo, follow these steps:

  • Copy the src directory to yourProject

  • Add the following dependencies to build.gradle

    implementation('org.testng:testng:7.0.0')
    implementation('com.deque.html.axe-core:selenium:4.8.0')
    

If you would like to parallel run SitesAdminTest, follow this guide:

Run single test in the class

Intellij

  • Right-click on the method name in the code editor and select:

    • Run testLogin()
  • Click on the method name in the code editor and press the key combination:

    • ctrl + shift + F10

Command Line

  • Run ./gradlew clean test --tests SearchTest.testSearchByKeywords

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages