Nagaytseva #5
156
Nagaytseva/.gitignore
vendored
Normal file
156
Nagaytseva/.gitignore
vendored
Normal file
@ -0,0 +1,156 @@
|
||||
|
||||
# Created by https://www.gitignore.io/api/intellij,java,maven,gradle,eclipse,netbeans
|
||||
|
||||
### Intellij ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
||||
|
||||
*.iml
|
||||
nb-configuration.xml
|
||||
|
||||
## Directory-based project format:
|
||||
.idea/
|
||||
.target
|
||||
# if you remove the above rule, at least ignore the following:
|
||||
|
||||
# User-specific stuff:
|
||||
# .idea/workspace.xml
|
||||
# .idea/tasks.xml
|
||||
# .idea/dictionaries
|
||||
# .idea/shelf
|
||||
|
||||
# Sensitive or high-churn files:
|
||||
# .idea/dataSources.ids
|
||||
# .idea/dataSources.xml
|
||||
# .idea/sqlDataSources.xml
|
||||
# .idea/dynamic.xml
|
||||
# .idea/uiDesigner.xml
|
||||
|
||||
# Gradle:
|
||||
# .idea/gradle.xml
|
||||
# .idea/libraries
|
||||
|
||||
# Mongo Explorer plugin:
|
||||
# .idea/mongoSettings.xml
|
||||
|
||||
## File-based project format:
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
## Plugin-specific files:
|
||||
|
||||
# IntelliJ
|
||||
/out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
|
||||
### Java ###
|
||||
*.class
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
|
||||
### Maven ###
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
|
||||
|
||||
### Gradle ###
|
||||
.gradle
|
||||
build/
|
||||
|
||||
# Ignore Gradle GUI config
|
||||
gradle-app.setting
|
||||
|
||||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||
!gradle-wrapper.jar
|
||||
|
||||
# Cache of project
|
||||
.gradletasknamecache
|
||||
|
||||
|
||||
### Eclipse ###
|
||||
|
||||
.metadata
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.settings/
|
||||
.loadpath
|
||||
|
||||
# Eclipse Core
|
||||
.project
|
||||
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
# Locally stored "Eclipse launch configurations"
|
||||
*.launch
|
||||
|
||||
# PyDev specific (Python IDE for Eclipse)
|
||||
*.pydevproject
|
||||
|
||||
# CDT-specific (C/C++ Development Tooling)
|
||||
.cproject
|
||||
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
.classpath
|
||||
|
||||
# Java annotation processor (APT)
|
||||
.factorypath
|
||||
|
||||
# PDT-specific (PHP Development Tools)
|
||||
.buildpath
|
||||
|
||||
# sbteclipse plugin
|
||||
.target
|
||||
|
||||
# TeXlipse plugin
|
||||
.texlipse
|
||||
|
||||
# STS (Spring Tool Suite)
|
||||
.springBeans
|
||||
|
||||
|
||||
### NetBeans ###
|
||||
nbproject/private/
|
||||
build/
|
||||
nbbuild/
|
||||
dist/
|
||||
nbdist/
|
||||
nbactions.xml
|
||||
.nb-gradle/
|
||||
|
||||
*.log
|
||||
|
||||
csv/
|
2
Nagaytseva/README.md
Normal file
2
Nagaytseva/README.md
Normal file
@ -0,0 +1,2 @@
|
||||
Selenium WebDriver example project
|
||||
|
49
Nagaytseva/pom.xml
Normal file
49
Nagaytseva/pom.xml
Normal file
@ -0,0 +1,49 @@
|
||||
<?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>tis-2017</groupId>
|
||||
<artifactId>tis-2017</artifactId>
|
||||
<version>1.0</version>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</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>3.6.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.1.0-RC1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<index>true</index>
|
||||
<manifest>
|
||||
<addClasspath>true</addClasspath>
|
||||
<classpathPrefix>lib/</classpathPrefix>
|
||||
<mainClass>ru.ulstu.tis.Main</mainClass>
|
||||
</manifest>
|
||||
<manifestEntries>
|
||||
<Class-Path>lib/</Class-Path>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
8
Nagaytseva/src/main/java/ru/ulstu/tis/Main.java
Normal file
8
Nagaytseva/src/main/java/ru/ulstu/tis/Main.java
Normal file
@ -0,0 +1,8 @@
|
||||
package ru.ulstu.tis;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("666");
|
||||
}
|
||||
}
|
BIN
Nagaytseva/src/main/resources/drivers/chromedriver
Normal file
BIN
Nagaytseva/src/main/resources/drivers/chromedriver
Normal file
Binary file not shown.
BIN
Nagaytseva/src/main/resources/drivers/chromedriver.exe
Normal file
BIN
Nagaytseva/src/main/resources/drivers/chromedriver.exe
Normal file
Binary file not shown.
BIN
Nagaytseva/src/main/resources/drivers/geckodriver
Normal file
BIN
Nagaytseva/src/main/resources/drivers/geckodriver
Normal file
Binary file not shown.
BIN
Nagaytseva/src/main/resources/drivers/geckodriver.exe
Normal file
BIN
Nagaytseva/src/main/resources/drivers/geckodriver.exe
Normal file
Binary file not shown.
40
Nagaytseva/src/test/java/GithubUserSearch.java
Normal file
40
Nagaytseva/src/test/java/GithubUserSearch.java
Normal file
@ -0,0 +1,40 @@
|
||||
import context.ChromeContext;
|
||||
import context.Context;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openqa.selenium.Dimension;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
import page.SearchPage;
|
||||
|
||||
|
||||
public class GithubUserSearch {
|
||||
private final static String APP_URL = "https://github.com/";
|
||||
|
||||
private static Context context;
|
||||
|
||||
@BeforeAll
|
||||
public static void setup() {
|
||||
context = new ChromeContext();
|
||||
context.start();
|
||||
context.getDriver().manage().window().setSize(new Dimension(1600, 900));
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void quit() {
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResultPageHeader() {
|
||||
context.getDriver().get(APP_URL);
|
||||
String searchString = "romanov73";
|
||||
|
||||
SearchPage page = PageFactory.initElements(context.getDriver(), SearchPage.class);
|
||||
page.setSearchString(searchString);
|
||||
page.clickSubmitButton();
|
||||
page.clickUsersLink();
|
||||
Assertions.assertTrue(page.isUserPresent());
|
||||
}
|
||||
}
|
38
Nagaytseva/src/test/java/MenuNavigation.java
Normal file
38
Nagaytseva/src/test/java/MenuNavigation.java
Normal file
@ -0,0 +1,38 @@
|
||||
import context.ChromeContext;
|
||||
import context.Context;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openqa.selenium.Dimension;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
import page.PageMenu;
|
||||
import page.SearchPage;
|
||||
|
||||
public class MenuNavigation {
|
||||
private final static String APP_URL = "https://1c.ru/";
|
||||
|
||||
private static Context context;
|
||||
|
||||
@BeforeAll
|
||||
public static void setup() {
|
||||
context = new ChromeContext();
|
||||
context.start();
|
||||
context.getDriver().manage().window().setSize(new Dimension(1600, 900));
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void quit() {
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResultPageHeader() {
|
||||
context.getDriver().get(APP_URL);
|
||||
|
||||
PageMenu page = PageFactory.initElements(context.getDriver(), PageMenu.class);
|
||||
|
||||
page.clickUsersLink();
|
||||
Assertions.assertTrue(page.menuMin());
|
||||
}
|
||||
}
|
24
Nagaytseva/src/test/java/context/ChromeContext.java
Normal file
24
Nagaytseva/src/test/java/context/ChromeContext.java
Normal file
@ -0,0 +1,24 @@
|
||||
package context;
|
||||
|
||||
import org.openqa.selenium.chrome.ChromeDriver;
|
||||
|
||||
public class ChromeContext extends Context {
|
||||
private final static String WINDOWS_DRIVER = "chromedriver.exe";
|
||||
private final static String LINUX_DRIVER = "chromedriver";
|
||||
private final static String DRIVER_TYPE = "webdriver.chrome.driver";
|
||||
|
||||
@Override
|
||||
protected void createDriver() {
|
||||
driver = new ChromeDriver();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDriverExecutable(boolean isWindows) {
|
||||
return isWindows ? WINDOWS_DRIVER : LINUX_DRIVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDriverType() {
|
||||
return DRIVER_TYPE;
|
||||
}
|
||||
}
|
43
Nagaytseva/src/test/java/context/Context.java
Normal file
43
Nagaytseva/src/test/java/context/Context.java
Normal file
@ -0,0 +1,43 @@
|
||||
package context;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public abstract class Context {
|
||||
private final static String DRIVER_LOCATION = "drivers/%s";
|
||||
protected WebDriver driver;
|
||||
|
||||
public WebDriver getDriver() {
|
||||
if (driver != null) {
|
||||
return driver;
|
||||
}
|
||||
throw new IllegalStateException("WebDriver is not initialized");
|
||||
}
|
||||
|
||||
public void start() {
|
||||
System.setProperty(getDriverType(), getDriverExecutablePath());
|
||||
createDriver();
|
||||
// это плохая инструкция для автотестов, т.к. лучше задавать для конкретного элемента или кейса
|
||||
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
driver.quit();
|
||||
}
|
||||
|
||||
protected abstract void createDriver();
|
||||
|
||||
protected abstract String getDriverType();
|
||||
|
||||
protected abstract String getDriverExecutable(boolean windows);
|
||||
|
||||
private String getDriverExecutablePath() {
|
||||
return Context.class.getClassLoader().getResource(
|
||||
String.format(DRIVER_LOCATION, getDriverExecutable(isWindows()))).getFile();
|
||||
}
|
||||
|
||||
private boolean isWindows() {
|
||||
return System.getProperty("os.name").toLowerCase().contains("windows");
|
||||
}
|
||||
}
|
24
Nagaytseva/src/test/java/context/FirefoxContext.java
Normal file
24
Nagaytseva/src/test/java/context/FirefoxContext.java
Normal file
@ -0,0 +1,24 @@
|
||||
package context;
|
||||
|
||||
import org.openqa.selenium.firefox.FirefoxDriver;
|
||||
|
||||
public class FirefoxContext extends Context {
|
||||
private final static String WINDOWS_DRIVER = "geckodriver.exe";
|
||||
private final static String LINUX_DRIVER = "geckodriver";
|
||||
private final static String DRIVER_TYPE = "webdriver.gecko.driver";
|
||||
|
||||
@Override
|
||||
protected void createDriver() {
|
||||
driver = new FirefoxDriver();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDriverExecutable(boolean isWindows) {
|
||||
return isWindows ? WINDOWS_DRIVER : LINUX_DRIVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDriverType() {
|
||||
return DRIVER_TYPE;
|
||||
}
|
||||
}
|
27
Nagaytseva/src/test/java/page/PageMenu.java
Normal file
27
Nagaytseva/src/test/java/page/PageMenu.java
Normal file
@ -0,0 +1,27 @@
|
||||
package page;
|
||||
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
|
||||
public class PageMenu {
|
||||
WebDriver driver;
|
||||
|
||||
public PageMenu(WebDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
public void clickUsersLink() {
|
||||
driver.findElement(By.className("droppable")).findElement(By.tagName("span")).click();
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public boolean menuMin(){
|
||||
return !(driver.findElement(By.xpath("/html/body/div[1]/div[1]/div/div[2]/div[2]/ul/div/li[1]/a")).isDisplayed());
|
||||
|
||||
}
|
||||
/* public void clickUsersLink() {
|
||||
driver.findElement(By.className("droppable")).click();
|
||||
}*/
|
||||
}
|
38
Nagaytseva/src/test/java/page/SearchPage.java
Normal file
38
Nagaytseva/src/test/java/page/SearchPage.java
Normal file
@ -0,0 +1,38 @@
|
||||
package page;
|
||||
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.Keys;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
||||
public class SearchPage {
|
||||
WebDriver driver;
|
||||
|
||||
@FindBy(css = "input.header-search-input")
|
||||
private WebElement inputField;
|
||||
|
||||
@FindBy(xpath = "//*[@class='menu border']/a[7]")
|
||||
private WebElement usersLink;
|
||||
|
||||
public SearchPage(WebDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public SearchPage setSearchString(String text) {
|
||||
inputField.sendKeys(text);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void clickSubmitButton() {
|
||||
inputField.sendKeys(Keys.RETURN);
|
||||
}
|
||||
|
||||
public void clickUsersLink() {
|
||||
usersLink.click();
|
||||
}
|
||||
|
||||
public boolean isUserPresent() {
|
||||
return driver.findElement(By.cssSelector(".user-list-info")).isDisplayed();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user