-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e846b8e
commit 7b5db4e
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package pages; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
|
||
public class WysiwygEditorPage { | ||
|
||
private WebDriver driver; | ||
private String editorIframeId = "mce_0_ifr"; | ||
private By textArea = By.id("tinymce"); | ||
private By decreaseIndentButton = By.cssSelector("#mceu_12 button"); | ||
|
||
public WysiwygEditorPage(WebDriver driver){ | ||
this.driver = driver; | ||
} | ||
|
||
public void clearTextArea(){ | ||
switchToEditArea(); | ||
driver.findElement(textArea).clear(); | ||
switchToMainArea(); | ||
} | ||
|
||
public void setTextArea(String text){ | ||
switchToEditArea(); | ||
driver.findElement(textArea).sendKeys(text); | ||
switchToMainArea(); | ||
} | ||
|
||
public String getTextFromEditor(){ | ||
switchToEditArea(); | ||
String text = driver.findElement(textArea).getText(); | ||
switchToMainArea(); | ||
return text; | ||
} | ||
|
||
public void decreaseIndention(){ | ||
driver.findElement(decreaseIndentButton).click(); | ||
} | ||
|
||
private void switchToEditArea(){ | ||
driver.switchTo().frame(editorIframeId); | ||
} | ||
|
||
private void switchToMainArea(){ | ||
driver.switchTo().parentFrame(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package frames; | ||
|
||
import base.BaseTests; | ||
import org.testng.annotations.Test; | ||
|
||
import static org.testng.Assert.assertEquals; | ||
|
||
public class FrameTests extends BaseTests { | ||
|
||
@Test | ||
public void testWysiwyg(){ | ||
var editorPage = homePage.clickWysiwygEditor(); | ||
editorPage.clearTextArea(); | ||
|
||
String text1 = "hello "; | ||
String text2 = "world"; | ||
|
||
editorPage.setTextArea(text1); | ||
editorPage.decreaseIndention(); | ||
editorPage.setTextArea(text2); | ||
|
||
assertEquals(editorPage.getTextFromEditor(), text1+text2, "Text from editor is incorrect"); | ||
} | ||
} |