Kyrnaev #9
@ -25,35 +25,15 @@ public class DownloadTests
|
||||
|
||||
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) {
|
||||
}
|
||||
context.wait(10);
|
||||
page.clickPreviewLink();
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(5); // Same as Thread.sleep(5000);
|
||||
// The "main" thread will sleep
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
context.wait(5);
|
||||
page1.clickDownloadLink();
|
||||
context.switchTab(1);
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(8); // Same as Thread.sleep(5000);
|
||||
// The "main" thread will sleep
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
context.wait(10);
|
||||
page1.clickDownloadTorrentLink();
|
||||
|
||||
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(15); // Same as Thread.sleep(5000);
|
||||
// The "main" thread will sleep
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
|
||||
context.wait(15);
|
||||
Assertions.assertTrue(GamePage.isDownloadPagePresent());
|
||||
|
||||
context.switchTab(0);
|
||||
|
||||
|
||||
|
79
kurnaev/src/test/java/FilterTests.java
Normal file
79
kurnaev/src/test/java/FilterTests.java
Normal file
@ -0,0 +1,79 @@
|
||||
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 FilterTests
|
||||
{
|
||||
private final static String APP_URL = "http://gmt-max.net/";
|
||||
private static Context context;
|
||||
|
||||
@Test
|
||||
public void searchWordOnSite()
|
||||
{
|
||||
|
||||
Context.getDriver().get(APP_URL);
|
||||
|
||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||
|
||||
context.wait(10);
|
||||
page.search("Skyrim");
|
||||
context.wait(5);
|
||||
Assertions.assertTrue(MainPage.isSearchResultsPresent());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void searchNothingOnSite()
|
||||
{
|
||||
|
||||
Context.getDriver().get(APP_URL);
|
||||
|
||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||
|
||||
context.wait(10);
|
||||
page.search("");
|
||||
context.wait(5);
|
||||
Assertions.assertTrue(MainPage.isSearchResultsPresent());
|
||||
|
||||
|
||||
}
|
||||
@Test
|
||||
public void sortByMMORPGLink()
|
||||
{
|
||||
|
||||
Context.getDriver().get(APP_URL);
|
||||
|
||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||
context.wait(10);
|
||||
page.clickSideMenuLink();
|
||||
context.wait(5);
|
||||
page.clickSideMenuSubLink();
|
||||
context.wait(5);
|
||||
Assertions.assertTrue(MainPage.isSideMenuLinkPresent());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
46
kurnaev/src/test/java/MultimediaTests.java
Normal file
46
kurnaev/src/test/java/MultimediaTests.java
Normal file
@ -0,0 +1,46 @@
|
||||
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 MultimediaTests
|
||||
{
|
||||
private final static String APP_URL = "http://gmt-max.net/";
|
||||
private static Context context;
|
||||
|
||||
@Test
|
||||
public void checkPictures()
|
||||
{
|
||||
|
||||
Context.getDriver().get(APP_URL);
|
||||
|
||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||
GamePage page1 = PageFactory.initElements(context.getDriver(), GamePage.class);
|
||||
context.wait(10);
|
||||
page.clickPreviewLink();
|
||||
context.wait(5);
|
||||
Assertions.assertTrue(GamePage.isPicturePresent());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
@ -28,17 +28,9 @@ public class NavigationTests
|
||||
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) {
|
||||
}
|
||||
context.wait(10);
|
||||
page.clickRulesLink();
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(5); // Same as Thread.sleep(5000);
|
||||
// The "main" thread will sleep
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
context.wait(5);
|
||||
Assertions.assertTrue(MainPage.isRulesPresent());
|
||||
|
||||
|
||||
@ -50,17 +42,9 @@ public class NavigationTests
|
||||
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) {
|
||||
}
|
||||
context.wait(10);
|
||||
page.clickPreviewLink();
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(5); // Same as Thread.sleep(5000);
|
||||
// The "main" thread will sleep
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
context.wait(5);
|
||||
Assertions.assertTrue(MainPage.isPreviewPresent());
|
||||
|
||||
|
||||
@ -72,17 +56,9 @@ public class NavigationTests
|
||||
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) {
|
||||
}
|
||||
context.wait(10);
|
||||
page.clickpopularGiveup();
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(5); // Same as Thread.sleep(5000);
|
||||
// The "main" thread will sleep
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
context.wait(5);
|
||||
Assertions.assertTrue(MainPage.isPopularGiveupPresent());
|
||||
|
||||
|
||||
@ -94,17 +70,9 @@ public class NavigationTests
|
||||
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) {
|
||||
}
|
||||
context.wait(10);
|
||||
page.clickexternalLink();
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(5); // Same as Thread.sleep(5000);
|
||||
// The "main" thread will sleep
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
context.wait(5);
|
||||
Assertions.assertTrue(MainPage.isExternalLinkPresent());
|
||||
|
||||
|
||||
@ -116,17 +84,9 @@ public class NavigationTests
|
||||
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) {
|
||||
}
|
||||
context.wait(10);
|
||||
page.clicklastMessageLink();
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(5); // Same as Thread.sleep(5000);
|
||||
// The "main" thread will sleep
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
context.wait(5);
|
||||
Assertions.assertTrue(MainPage.islastMessageLinkPresent());
|
||||
|
||||
|
||||
@ -138,23 +98,11 @@ public class NavigationTests
|
||||
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) {
|
||||
}
|
||||
context.wait(10);
|
||||
page.clickSideMenuLink();
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(5); // Same as Thread.sleep(5000);
|
||||
// The "main" thread will sleep
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
context.wait(5);
|
||||
page.clickSideMenuSubLink();
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(5); // Same as Thread.sleep(5000);
|
||||
// The "main" thread will sleep
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
context.wait(5);
|
||||
Assertions.assertTrue(MainPage.isSideMenuLinkPresent());
|
||||
|
||||
|
||||
|
@ -34,6 +34,13 @@ public abstract class Context {
|
||||
driver.quit();
|
||||
}
|
||||
|
||||
public void wait(int sec) {
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(sec);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public void switchTab(int tabNum) { driver.switchTo().window(new ArrayList<String>(driver.getWindowHandles()).get(tabNum).toString()); }
|
||||
|
||||
protected abstract void createDriver();
|
||||
|
@ -42,6 +42,16 @@ public class GamePage
|
||||
}
|
||||
|
||||
}
|
||||
public static boolean isPicturePresent() {
|
||||
try {
|
||||
return driver.findElement(By.xpath("//html/body/div[@class='content_main']/div[@class='main_center_col blocks']")).getAttribute("innerHTML").indexOf("<img src=\"http://paypic.kz/allimage/") >= 0;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -33,6 +33,9 @@ public class MainPage {
|
||||
@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;
|
||||
|
||||
@FindBy(id = "story")
|
||||
private WebElement searchField;
|
||||
|
||||
public MainPage(WebDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
@ -49,6 +52,7 @@ public class MainPage {
|
||||
public void clicklastMessageLink() { lastMessageLink.click(); }
|
||||
public void clickSideMenuLink() { sideMenuLink.click(); }
|
||||
public void clickSideMenuSubLink() { sideMenuSubLink.click(); }
|
||||
public void search(String word) {searchField.sendKeys(word + "\n");}
|
||||
|
||||
public static boolean isRulesPresent() {
|
||||
try {
|
||||
@ -116,4 +120,16 @@ public class MainPage {
|
||||
}
|
||||
|
||||
}
|
||||
public static boolean isSearchResultsPresent() {
|
||||
try {
|
||||
|
||||
return driver.findElement(By.xpath("//html/body/div[@class='content_main']/div[@class='main_center_col blocks']/div[@id='dle-content']/div[@class='dpad radial infoblock']")).getAttribute("innerHTML").indexOf("value=\"Начать поиск\"") >= 0;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user