ProduceMessagePage.java 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package com.provectus.kafka.ui.pages;
  2. import com.codeborne.selenide.Condition;
  3. import com.codeborne.selenide.SelenideElement;
  4. import com.provectus.kafka.ui.pages.topic.TopicView;
  5. import org.openqa.selenium.By;
  6. import org.openqa.selenium.Keys;
  7. import org.openqa.selenium.support.ui.ExpectedConditions;
  8. import static com.codeborne.selenide.Selenide.$;
  9. import static com.codeborne.selenide.Selenide.Wait;
  10. public class ProduceMessagePage{
  11. private final SelenideElement keyField = $(By.xpath("//div[@id = 'key']/textarea"));
  12. private final SelenideElement contentField = $(By.xpath("//div[@id = 'content']/textarea"));
  13. private final SelenideElement headersField = $(By.xpath("//div[@id = 'headers']/textarea"));
  14. private final SelenideElement sendBtn = $(By.xpath("//button[@type = 'submit']"));
  15. public ProduceMessagePage setKeyField(String value) {
  16. Wait().until(ExpectedConditions.urlContains("message"));
  17. keyField.sendKeys(Keys.chord(Keys.DELETE));
  18. keyField.setValue(value);
  19. return this;
  20. }
  21. public ProduceMessagePage setContentFiled(String value) {
  22. Wait().until(ExpectedConditions.urlContains("message"));
  23. contentField.sendKeys(Keys.DELETE);
  24. contentField.setValue(value);
  25. return this;
  26. }
  27. public ProduceMessagePage setHeaderFiled(String value) {
  28. headersField.setValue(value);
  29. return new ProduceMessagePage();
  30. }
  31. public TopicView submitProduceMessage() {
  32. sendBtn.shouldBe(Condition.visible).click();
  33. return new TopicView();
  34. }
  35. }