ConsultantTest.java добавлен @Test isBeContextMenu()
BpPage.java добавлен метод openContextMenuByDoc()
This commit is contained in:
parent
9bde5a8c3d
commit
be1da7e4c1
@ -5,27 +5,29 @@ import com.codeborne.selenide.Selenide;
|
|||||||
import com.codeborne.selenide.SelenideElement;
|
import com.codeborne.selenide.SelenideElement;
|
||||||
import org.openqa.selenium.By;
|
import org.openqa.selenium.By;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static com.codeborne.selenide.Condition.visible;
|
import static com.codeborne.selenide.Condition.visible;
|
||||||
import static com.codeborne.selenide.Selenide.$;
|
import static com.codeborne.selenide.Selenide.*;
|
||||||
import static com.codeborne.selenide.Selenide.$$;
|
import static java.time.temporal.ChronoUnit.SECONDS;
|
||||||
|
|
||||||
public class BpPage {
|
public class BpPage {
|
||||||
public static final By searchField = By.cssSelector("[test*='page-home-input']");
|
public static final By searchField = By.cssSelector("[test*='page-home-input']");
|
||||||
public static final By searchButton = By.cssSelector("[class*='x-search-box__search-button'], [test*='page-home-search-button']");
|
public static final By searchButton = By.cssSelector("[class*='x-search-box__search-button'], [test*='page-home-search-button']");
|
||||||
public static final By searchList = By.cssSelector("div.x-page-components-search-result-item");
|
public static final By searchList = By.cssSelector("div.x-page-components-search-result-item");
|
||||||
|
public static final By contextMenu = By.cssSelector("[class='x-menu'], [test='menu']");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Делаем запрос в БП
|
* Делаем запрос в БП
|
||||||
*
|
*
|
||||||
* @param query запрос
|
* @param query запрос
|
||||||
* @throws InterruptedException
|
|
||||||
*/
|
*/
|
||||||
public static void searchInInputField(String query) throws InterruptedException {
|
public static void searchInInputField(String query) {
|
||||||
$(searchField).setValue(query);
|
$(searchField).setValue(query);
|
||||||
$(searchButton).click();
|
$(searchButton).click();
|
||||||
TimeUnit.SECONDS.sleep(2);
|
$(searchList).shouldBe(visible, Duration.of(3, SECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,10 +35,21 @@ public class BpPage {
|
|||||||
* @param index индекс документа (начинается с 0)
|
* @param index индекс документа (начинается с 0)
|
||||||
* @return SelenideElement
|
* @return SelenideElement
|
||||||
*/
|
*/
|
||||||
public static SelenideElement takeFocusOnDocByIndex(int index) {
|
public static SelenideElement getOnDocByIndex(int index) {
|
||||||
ElementsCollection list = $$(searchList);
|
ElementsCollection list = $$(searchList);
|
||||||
list.get(0).shouldBe(visible);
|
list.get(0).shouldBe(visible);
|
||||||
|
|
||||||
return list.get(0);
|
return list.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Открытие контекстного меню по ПКП
|
||||||
|
* @param index индекс документа (начинается с 0)
|
||||||
|
*/
|
||||||
|
public static void openContextMenuByDoc(int index) {
|
||||||
|
SelenideElement doc = getOnDocByIndex(index);
|
||||||
|
|
||||||
|
doc.contextClick();
|
||||||
|
$(contextMenu).shouldBe(visible, Duration.of(3, SECONDS));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import com.codeborne.selenide.Selenide;
|
import com.codeborne.selenide.Selenide;
|
||||||
import com.codeborne.selenide.SelenideElement;
|
import com.codeborne.selenide.SelenideElement;
|
||||||
|
import static com.codeborne.selenide.Selenide.*;
|
||||||
import org.testng.Assert;
|
import org.testng.Assert;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
import page.BpPage;
|
import page.BpPage;
|
||||||
@ -9,7 +10,7 @@ public class ConsultantTest extends BaseTest{
|
|||||||
private final static String TKrf = "Трудовой кодекс";
|
private final static String TKrf = "Трудовой кодекс";
|
||||||
|
|
||||||
@Test(description = "Проверка поиска в БП")
|
@Test(description = "Проверка поиска в БП")
|
||||||
public void searchInBp() throws InterruptedException {
|
public void searchInBp() {
|
||||||
// Открываем БП
|
// Открываем БП
|
||||||
StartPage.openBP();
|
StartPage.openBP();
|
||||||
|
|
||||||
@ -17,12 +18,21 @@ public class ConsultantTest extends BaseTest{
|
|||||||
BpPage.searchInInputField("закон о полиции");
|
BpPage.searchInInputField("закон о полиции");
|
||||||
|
|
||||||
// Проверяем текст документа по индексу
|
// Проверяем текст документа по индексу
|
||||||
SelenideElement doc = BpPage.takeFocusOnDocByIndex(0);
|
SelenideElement doc = BpPage.getOnDocByIndex(0);
|
||||||
boolean isCorrectTitle = doc.getText().contains("О полиции");
|
boolean isCorrectTitle = doc.getText().contains("О полиции");
|
||||||
|
|
||||||
Assert.assertTrue(isCorrectTitle, "Документы отличаются");
|
Assert.assertTrue(isCorrectTitle, "Документы отличаются");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(description = "Проверка вызова контекстного меню по ПКМ")
|
||||||
|
public void isBeContextMenu() {
|
||||||
|
StartPage.openBP();
|
||||||
|
BpPage.searchInInputField(TKrf);
|
||||||
|
|
||||||
|
BpPage.openContextMenuByDoc(0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user