-
Notifications
You must be signed in to change notification settings - Fork 3
Initializing seleniumJavaExperiment #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
d3df2d4
a61c00c
b4024ab
f27b9aa
198de03
fc7f368
129e8bf
99231d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
|
||
# Created by https://www.toptal.com/developers/gitignore/api/intellij,macos,java | ||
# Edit at https://www.toptal.com/developers/gitignore?templates=intellij,macos,java | ||
|
||
### Intellij ### | ||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
# User-specific stuff | ||
.idea/**/workspace.xml | ||
.idea/**/tasks.xml | ||
.idea/**/usage.statistics.xml | ||
.idea/**/dictionaries | ||
.idea/**/shelf | ||
|
||
# AWS User-specific | ||
.idea/**/aws.xml | ||
|
||
# Generated files | ||
.idea/**/contentModel.xml | ||
|
||
# Sensitive or high-churn files | ||
.idea/**/dataSources/ | ||
.idea/**/dataSources.ids | ||
.idea/**/dataSources.local.xml | ||
.idea/**/sqlDataSources.xml | ||
.idea/**/dynamic.xml | ||
.idea/**/uiDesigner.xml | ||
.idea/**/dbnavigator.xml | ||
|
||
# Gradle | ||
.idea/**/gradle.xml | ||
.idea/**/libraries | ||
|
||
# Gradle and Maven with auto-import | ||
# When using Gradle or Maven with auto-import, you should exclude module files, | ||
# since they will be recreated, and may cause churn. Uncomment if using | ||
# auto-import. | ||
# .idea/artifacts | ||
# .idea/compiler.xml | ||
# .idea/jarRepositories.xml | ||
# .idea/modules.xml | ||
# .idea/*.iml | ||
# .idea/modules | ||
# *.iml | ||
# *.ipr | ||
|
||
# CMake | ||
cmake-build-*/ | ||
|
||
# Mongo Explorer plugin | ||
.idea/**/mongoSettings.xml | ||
|
||
# File-based project format | ||
*.iws | ||
|
||
# IntelliJ | ||
out/ | ||
|
||
# mpeltonen/sbt-idea plugin | ||
.idea_modules/ | ||
|
||
# JIRA plugin | ||
atlassian-ide-plugin.xml | ||
|
||
# Cursive Clojure plugin | ||
.idea/replstate.xml | ||
|
||
# SonarLint plugin | ||
.idea/sonarlint/ | ||
|
||
# Crashlytics plugin (for Android Studio and IntelliJ) | ||
com_crashlytics_export_strings.xml | ||
crashlytics.properties | ||
crashlytics-build.properties | ||
fabric.properties | ||
|
||
# Editor-based Rest Client | ||
.idea/httpRequests | ||
|
||
# Android studio 3.1+ serialized cache file | ||
.idea/caches/build_file_checksums.ser | ||
|
||
### Intellij Patch ### | ||
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 | ||
|
||
# *.iml | ||
# modules.xml | ||
# .idea/misc.xml | ||
# *.ipr | ||
|
||
# Sonarlint plugin | ||
# https://plugins.jetbrains.com/plugin/7973-sonarlint | ||
.idea/**/sonarlint/ | ||
|
||
# SonarQube Plugin | ||
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin | ||
.idea/**/sonarIssues.xml | ||
|
||
# Markdown Navigator plugin | ||
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced | ||
.idea/**/markdown-navigator.xml | ||
.idea/**/markdown-navigator-enh.xml | ||
.idea/**/markdown-navigator/ | ||
|
||
# Cache file creation bug | ||
# See https://youtrack.jetbrains.com/issue/JBR-2257 | ||
.idea/$CACHE_FILE$ | ||
|
||
# CodeStream plugin | ||
# https://plugins.jetbrains.com/plugin/12206-codestream | ||
.idea/codestream.xml | ||
|
||
### Java ### | ||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
replay_pid* | ||
|
||
### macOS ### | ||
# General | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
|
||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
# End of https://www.toptal.com/developers/gitignore/api/intellij,macos,java |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<div id="top"></div> | ||
|
||
<!-- PROJECT SHIELDS --> | ||
[](https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java) | ||
[](https://www.oracle.com/java/technologies/downloads/#jdk17-mac) | ||
|
||
<!-- PROJECT LOGO --> | ||
<br /> | ||
<div align="center"> | ||
<p align="center"> | ||
<a href="https://www.selenium.dev/"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/9f/Selenium_logo.svg/1280px-Selenium_logo.svg.png"/></a> | ||
</p> | ||
|
||
<h3 align="center">Selenium Java Experiment</h3> | ||
</div> | ||
|
||
<!-- ABOUT THE PROJECT --> | ||
## About The Project | ||
|
||
The main goal of this experiment is to share with the community how `Selenium Webdriver` works along with Java as a testing framework and to learn how nowadays test automation projects are set up and worked utilizing the latest design patterns and frameworks, e.g. TestNG. This project has been built using POM / Page Factory, read [this article](https://www.browserstack.com/guide/page-object-model-in-selenium) to learn more. The testing subject for this experiment is this website — [http://the-internet.herokuapp.com/](http://the-internet.herokuapp.com/). | ||
|
||
<p align="right">(<a href="#top">back to top</a>)</p> | ||
|
||
<!-- GETTING STARTED --> | ||
## Getting Started | ||
|
||
### Prerequisites | ||
This is a Maven project, create the following under `<dependencies>` in your `pom.xml` file if they are not there already. | ||
|
||
* Selenium Webdriver | ||
```xml | ||
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java --> | ||
<dependency> | ||
<groupId>org.seleniumhq.selenium</groupId> | ||
<artifactId>selenium-java</artifactId> | ||
<version>4.1.1</version> | ||
</dependency> | ||
``` | ||
* TestNG Framework | ||
```xml | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<version>6.8</version> | ||
<scope>test</scope> | ||
</dependency> | ||
``` | ||
|
||
* Selenium Webdriver for Google Chrome v 97.0.4692.99. Download from [here](https://chromedriver.storage.googleapis.com/index.html?path=97.0.4692.71/) if needed. | ||
|
||
<p align="right">(<a href="#top">back to top</a>)</p> | ||
|
||
<!-- CONTACT --> | ||
## Contact | ||
Asim Khan - [@asimkhan](mailto:"[email protected]") | ||
|
||
Israel Alfaro - [@israelalfaro](mailto:"[email protected]") | ||
|
||
Pedro Hyvo - [@pedrohyvo](https://www.linkedin.com/in/pedrohyvo/) | ||
|
||
<p align="right">(<a href="#top">back to top</a>)</p> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.example</groupId> | ||
<artifactId>seleniumJavaExperiment</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java --> | ||
<dependency> | ||
<groupId>org.seleniumhq.selenium</groupId> | ||
<artifactId>selenium-java</artifactId> | ||
<version>4.1.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<version>7.5</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.chrome.ChromeDriver; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.support.PageFactory; | ||
import org.testng.Assert; | ||
import org.testng.annotations.AfterClass; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
import pageObjects.ABtestPage; | ||
import pageObjects.HomePage; | ||
|
||
public class SeleniumTests { | ||
|
||
WebDriver driver; | ||
|
||
HomePage homePage; | ||
ABtestPage abTestPage; | ||
|
||
@BeforeClass | ||
public void beforeClass () { | ||
System.setProperty("webdriver.chrome.driver", "./src/test/resources/chromedriver/chromedriver"); | ||
driver = new ChromeDriver(); | ||
driver.manage().window().maximize(); | ||
driver.get("http://the-internet.herokuapp.com/"); | ||
homePage = PageFactory.initElements(driver, HomePage.class); | ||
abTestPage = PageFactory.initElements(driver, ABtestPage.class); | ||
} | ||
|
||
@Test | ||
public void testNavigationToABtestPage () { | ||
homePage.clickOption("A/B Testing"); | ||
Assert.assertEquals("A/B Test Control", abTestPage.getTitleText()); | ||
} | ||
|
||
@AfterClass | ||
public void afterClass () { | ||
driver.quit(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package pageObjects; | ||
|
||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.support.FindBy; | ||
|
||
public class ABtestPage { | ||
|
||
@FindBy (css = ".example h3") | ||
WebElement pageTitle; | ||
|
||
public String getTitleText () { | ||
return pageTitle.getText(); | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.