- добавлен @Test searchInBp();
This commit is contained in:
parent
0c1f90a6e8
commit
2ed64a67df
@ -1,18 +1,39 @@
|
|||||||
package page;
|
package page;
|
||||||
|
|
||||||
|
import com.codeborne.selenide.ElementsCollection;
|
||||||
import org.openqa.selenium.By;
|
import org.openqa.selenium.By;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static com.codeborne.selenide.Selenide.$;
|
import static com.codeborne.selenide.Selenide.$;
|
||||||
|
import static com.codeborne.selenide.Selenide.$$;
|
||||||
|
|
||||||
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");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Делаем запрос в БП
|
||||||
|
*
|
||||||
|
* @param query запрос
|
||||||
|
* @throws InterruptedException
|
||||||
|
*/
|
||||||
public static void searchInInputField(String query) throws InterruptedException {
|
public static void searchInInputField(String query) throws InterruptedException {
|
||||||
$(searchField).setValue(query);
|
$(searchField).setValue(query);
|
||||||
$(searchButton).click();
|
$(searchButton).click();
|
||||||
TimeUnit.SECONDS.sleep(5);
|
TimeUnit.SECONDS.sleep(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получаем название документа по индексу из списка
|
||||||
|
*
|
||||||
|
* @param index индекс документа (от 0 до 9)
|
||||||
|
* @return название документа
|
||||||
|
*/
|
||||||
|
public static String returnTextFromIndexDocInList(int index) {
|
||||||
|
ElementsCollection list = $$(searchList);
|
||||||
|
|
||||||
|
return list.get(index).getText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import org.testng.Assert;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
import page.BpPage;
|
import page.BpPage;
|
||||||
import page.StartPage;
|
import page.StartPage;
|
||||||
@ -7,8 +8,17 @@ public class ConsultantTest extends BaseTest{
|
|||||||
|
|
||||||
@Test(description = "Проверка поиска в БП")
|
@Test(description = "Проверка поиска в БП")
|
||||||
public void searchInBp() throws InterruptedException {
|
public void searchInBp() throws InterruptedException {
|
||||||
|
// Открываем БП
|
||||||
StartPage.openBP();
|
StartPage.openBP();
|
||||||
|
|
||||||
|
// Делаем запрос в строку поиска
|
||||||
BpPage.searchInInputField("закон о полиции");
|
BpPage.searchInInputField("закон о полиции");
|
||||||
|
|
||||||
|
// Проверяем текст документа по индексу
|
||||||
|
String title = BpPage.returnTextFromIndexDocInList(0);
|
||||||
|
System.out.println(title);
|
||||||
|
boolean flag = title.contains("О полиции");
|
||||||
|
Assert.assertTrue(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user