первые 7 тестов
This commit is contained in:
parent
ad1ff0d77d
commit
eb549dabf4
73
kurnaev/src/test/java/DownloadTests.java
Normal file
73
kurnaev/src/test/java/DownloadTests.java
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
import org.openqa.selenium.support.PageFactory;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
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 context.ChromeContext;
|
||||||
|
import context.Context;
|
||||||
|
import page.MainPage;
|
||||||
|
import page.GamePage;
|
||||||
|
|
||||||
|
public class DownloadTests
|
||||||
|
{
|
||||||
|
|
||||||
|
private final static String APP_URL = "http://gmt-max.net/";
|
||||||
|
private static Context context;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void downloadTorrent()
|
||||||
|
{
|
||||||
|
|
||||||
|
Context.getDriver().get(APP_URL);
|
||||||
|
|
||||||
|
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||||
|
GamePage page1 = PageFactory.initElements(context.getDriver(), GamePage.class);
|
||||||
|
try {
|
||||||
|
TimeUnit.SECONDS.sleep(10); // Same as Thread.sleep(5000);
|
||||||
|
// The "main" thread will sleep
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
|
page.clickPreviewLink();
|
||||||
|
try {
|
||||||
|
TimeUnit.SECONDS.sleep(5); // Same as Thread.sleep(5000);
|
||||||
|
// The "main" thread will sleep
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
|
page1.clickDownloadLink();
|
||||||
|
context.switchTab(1);
|
||||||
|
try {
|
||||||
|
TimeUnit.SECONDS.sleep(8); // Same as Thread.sleep(5000);
|
||||||
|
// The "main" thread will sleep
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
|
page1.clickDownloadTorrentLink();
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
TimeUnit.SECONDS.sleep(15); // Same as Thread.sleep(5000);
|
||||||
|
// The "main" thread will sleep
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Assertions.assertTrue(GamePage.isDownloadPagePresent());
|
||||||
|
|
||||||
|
context.switchTab(0);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
public static void setup() {
|
||||||
|
context = new ChromeContext();
|
||||||
|
context.start();
|
||||||
|
//context.getDriver().manage().window().setSize(new Dimension(1366, 768));
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterAll
|
||||||
|
public static void quit() {
|
||||||
|
context.close();
|
||||||
|
}
|
||||||
|
}
|
@ -130,6 +130,34 @@ public class NavigationTests
|
|||||||
Assertions.assertTrue(MainPage.islastMessageLinkPresent());
|
Assertions.assertTrue(MainPage.islastMessageLinkPresent());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void sideMenuLink()
|
||||||
|
{
|
||||||
|
|
||||||
|
Context.getDriver().get(APP_URL);
|
||||||
|
|
||||||
|
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||||
|
try {
|
||||||
|
TimeUnit.SECONDS.sleep(10); // Same as Thread.sleep(5000);
|
||||||
|
// The "main" thread will sleep
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
|
page.clickSideMenuLink();
|
||||||
|
try {
|
||||||
|
TimeUnit.SECONDS.sleep(5); // Same as Thread.sleep(5000);
|
||||||
|
// The "main" thread will sleep
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
|
page.clickSideMenuSubLink();
|
||||||
|
try {
|
||||||
|
TimeUnit.SECONDS.sleep(5); // Same as Thread.sleep(5000);
|
||||||
|
// The "main" thread will sleep
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
|
Assertions.assertTrue(MainPage.isSideMenuLinkPresent());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setup() {
|
public static void setup() {
|
||||||
|
@ -3,6 +3,8 @@ package context;
|
|||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
import org.openqa.selenium.chrome.ChromeDriver;
|
import org.openqa.selenium.chrome.ChromeDriver;
|
||||||
import org.openqa.selenium.chrome.ChromeOptions;
|
import org.openqa.selenium.chrome.ChromeOptions;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
//import java.nio.file.*;
|
//import java.nio.file.*;
|
||||||
//import java.io.File;
|
//import java.io.File;
|
||||||
@ -32,6 +34,8 @@ public abstract class Context {
|
|||||||
driver.quit();
|
driver.quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void switchTab(int tabNum) { driver.switchTo().window(new ArrayList<String>(driver.getWindowHandles()).get(tabNum).toString()); }
|
||||||
|
|
||||||
protected abstract void createDriver();
|
protected abstract void createDriver();
|
||||||
|
|
||||||
protected abstract String getDriverType();
|
protected abstract String getDriverType();
|
||||||
|
47
kurnaev/src/test/java/page/GamePage.java
Normal file
47
kurnaev/src/test/java/page/GamePage.java
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package page;
|
||||||
|
|
||||||
|
import org.openqa.selenium.Keys;
|
||||||
|
import org.openqa.selenium.WebDriver;
|
||||||
|
import org.openqa.selenium.WebElement;
|
||||||
|
import org.openqa.selenium.support.FindBy;
|
||||||
|
import org.openqa.selenium.By;
|
||||||
|
import org.openqa.selenium.interactions.Actions;
|
||||||
|
|
||||||
|
public class GamePage
|
||||||
|
{
|
||||||
|
static WebDriver driver;
|
||||||
|
|
||||||
|
@FindBy(xpath = "//a[starts-with(@href,'/go.php?url=https://downloads-torrent.ru')]")
|
||||||
|
private WebElement downloadLink;
|
||||||
|
|
||||||
|
@FindBy(xpath = "//html/body[@class='rectangles']/main[@class='fill']/section[@class='section section--fill']/div[@class='container no-index']/div[@class='block block-download']/a[@id='btn--download']")
|
||||||
|
private WebElement downloadTorrentLink;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public GamePage(WebDriver driver) {
|
||||||
|
this.driver = driver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clickDownloadLink() {
|
||||||
|
downloadLink.click();
|
||||||
|
}
|
||||||
|
public void clickDownloadTorrentLink() {
|
||||||
|
downloadTorrentLink.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isDownloadPagePresent() {
|
||||||
|
try {
|
||||||
|
|
||||||
|
return driver.findElement(By.xpath("//html/body")).getText().indexOf("СКАЧАТЬ ТОРРЕНТ") >= 0;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -27,6 +27,12 @@ public class MainPage {
|
|||||||
@FindBy(xpath = "//html/body/div[@class='content'][1]/div[@class='forum_block']/div[@class='forum_msg_block']/div[@class='ltContent']/table/tbody/tr[7]/td[@class='topicInfo']/a[@class='topicLink']")
|
@FindBy(xpath = "//html/body/div[@class='content'][1]/div[@class='forum_block']/div[@class='forum_msg_block']/div[@class='ltContent']/table/tbody/tr[7]/td[@class='topicInfo']/a[@class='topicLink']")
|
||||||
private WebElement lastMessageLink;
|
private WebElement lastMessageLink;
|
||||||
|
|
||||||
|
@FindBy(xpath = "//html/body/div[@class='content_main']/div[@class='main_left_col blocks']/div[@id='firstpane'][2]/p[@class='menu_head1'][3]")
|
||||||
|
private WebElement sideMenuLink;
|
||||||
|
|
||||||
|
@FindBy(xpath = "//html/body/div[@class='content_main']/div[@class='main_left_col blocks']/div[@id='firstpane'][2]/div[@class='menu_body'][3]/a[2]")
|
||||||
|
private WebElement sideMenuSubLink;
|
||||||
|
|
||||||
public MainPage(WebDriver driver) {
|
public MainPage(WebDriver driver) {
|
||||||
this.driver = driver;
|
this.driver = driver;
|
||||||
}
|
}
|
||||||
@ -41,6 +47,8 @@ public class MainPage {
|
|||||||
public void clickpopularGiveup() { popularGiveup.click(); }
|
public void clickpopularGiveup() { popularGiveup.click(); }
|
||||||
public void clickexternalLink() { externalLink.click(); }
|
public void clickexternalLink() { externalLink.click(); }
|
||||||
public void clicklastMessageLink() { lastMessageLink.click(); }
|
public void clicklastMessageLink() { lastMessageLink.click(); }
|
||||||
|
public void clickSideMenuLink() { sideMenuLink.click(); }
|
||||||
|
public void clickSideMenuSubLink() { sideMenuSubLink.click(); }
|
||||||
|
|
||||||
public static boolean isRulesPresent() {
|
public static boolean isRulesPresent() {
|
||||||
try {
|
try {
|
||||||
@ -97,4 +105,15 @@ public class MainPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public static boolean isSideMenuLinkPresent() {
|
||||||
|
try {
|
||||||
|
|
||||||
|
return driver.findElement(By.xpath("//html/body/div[@class='content_main']/div[@class='main_content_nav']")).getText().indexOf("Rpg") >= 0;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user