105 lines
3.5 KiB
Java
105 lines
3.5 KiB
Java
import context.ChromeContext;
|
|
import context.Context;
|
|
import helpers.AutorizationHelper;
|
|
import helpers.SearchResultsPageHelper;
|
|
import org.junit.jupiter.api.*;
|
|
import org.openqa.selenium.Dimension;
|
|
import org.openqa.selenium.support.PageFactory;
|
|
import page.*;
|
|
|
|
import java.text.ParseException;
|
|
import java.util.Random;
|
|
|
|
|
|
public class Forms{
|
|
private final static String APP_URL = "https://doctor73.ru/";
|
|
|
|
private static Context context;
|
|
|
|
@BeforeEach
|
|
public void setup() {
|
|
context = new ChromeContext();
|
|
context.start();
|
|
context.getDriver().manage().window().setSize(new Dimension(1600, 900));
|
|
}
|
|
|
|
@AfterEach
|
|
public void quit() {
|
|
context.close();
|
|
}
|
|
|
|
|
|
@Test
|
|
public void sendQuestion() throws NoSuchMethodException, ParseException {
|
|
context.getDriver().get(APP_URL);
|
|
|
|
AutorizationHelper helper = new AutorizationHelper();
|
|
helper.autorization(context);
|
|
|
|
MainPageDoctor mainPage = PageFactory.initElements(context.getDriver(), MainPageDoctor.class);
|
|
mainPage.clickQuestionsAndAnswersPage();
|
|
|
|
QuestionsAndAnswersPage page = PageFactory.initElements(context.getDriver(), QuestionsAndAnswersPage.class);
|
|
Random r = new Random();
|
|
int randomNumber = r.nextInt();
|
|
String str = "/////////////////Тестовый комментарий номер"+randomNumber;
|
|
page.setText(str);
|
|
page.submitButtonClick();
|
|
Assertions.assertTrue(page.isQuestionPresent(str));
|
|
}
|
|
|
|
@Test
|
|
public void likeRewiew() throws NoSuchMethodException, ParseException {
|
|
context.getDriver().get(APP_URL);
|
|
|
|
AutorizationHelper helper = new AutorizationHelper();
|
|
helper.autorization(context);
|
|
|
|
MainPageDoctor mainPage = PageFactory.initElements(context.getDriver(), MainPageDoctor.class);
|
|
mainPage.clickAboutPage();
|
|
|
|
AboutPage aboutPage = PageFactory.initElements(context.getDriver(), AboutPage.class);
|
|
aboutPage.rewiewsClick();
|
|
|
|
ReviewsPage reviewsPage = PageFactory.initElements(context.getDriver(), ReviewsPage.class);
|
|
reviewsPage.likeRewiewClick();
|
|
String str1 ="Ваш голос учтен";
|
|
String str2 ="Ваш голос изменен";
|
|
try {
|
|
Thread.sleep(3000);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
//System.out.println(reviewsPage.getText());
|
|
Assertions.assertTrue(reviewsPage.getText().equals(str1)||reviewsPage.getText().equals(str2) );
|
|
}
|
|
|
|
@Test
|
|
public void sendRewiewWithError() throws NoSuchMethodException, ParseException {
|
|
context.getDriver().get(APP_URL);
|
|
|
|
AutorizationHelper helper = new AutorizationHelper();
|
|
helper.autorization(context);
|
|
|
|
MainPageDoctor mainPage = PageFactory.initElements(context.getDriver(), MainPageDoctor.class);
|
|
mainPage.clickAboutPage();
|
|
|
|
AboutPage aboutPage = PageFactory.initElements(context.getDriver(), AboutPage.class);
|
|
aboutPage.rewiewsClick();
|
|
|
|
ReviewsPage reviewsPage = PageFactory.initElements(context.getDriver(), ReviewsPage.class);
|
|
Random r = new Random();
|
|
int randomNumber = r.nextInt();
|
|
String str = "/////////////////Тестовый комментарий номер"+randomNumber;
|
|
reviewsPage.rewiewClick();
|
|
reviewsPage.setRewiewText(str);
|
|
reviewsPage.rewiewCheckClick();
|
|
reviewsPage.rewiewSubmitClick();
|
|
|
|
Assertions.assertTrue(reviewsPage.isErrorPresent());
|
|
}
|
|
|
|
|
|
|
|
}
|