File tree Expand file tree Collapse file tree 3 files changed +76
-0
lines changed Expand file tree Collapse file tree 3 files changed +76
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,11 @@ public FileUploadPage clickFileUpload(){
41
41
return new FileUploadPage (driver );
42
42
}
43
43
44
+ public WysiwygEditorPage clickWysiwygEditor (){
45
+ clickLink ("WYSIWYG Editor" );
46
+ return new WysiwygEditorPage (driver );
47
+ }
48
+
44
49
private void clickLink (String linkText ){
45
50
driver .findElement (By .linkText (linkText )).click ();
46
51
}
Original file line number Diff line number Diff line change
1
+ package pages ;
2
+
3
+ import org .openqa .selenium .By ;
4
+ import org .openqa .selenium .WebDriver ;
5
+
6
+ public class WysiwygEditorPage {
7
+
8
+ private WebDriver driver ;
9
+ private String editorIframeId = "mce_0_ifr" ;
10
+ private By textArea = By .id ("tinymce" );
11
+ private By decreaseIndentButton = By .cssSelector ("#mceu_12 button" );
12
+
13
+ public WysiwygEditorPage (WebDriver driver ){
14
+ this .driver = driver ;
15
+ }
16
+
17
+ public void clearTextArea (){
18
+ switchToEditArea ();
19
+ driver .findElement (textArea ).clear ();
20
+ switchToMainArea ();
21
+ }
22
+
23
+ public void setTextArea (String text ){
24
+ switchToEditArea ();
25
+ driver .findElement (textArea ).sendKeys (text );
26
+ switchToMainArea ();
27
+ }
28
+
29
+ public String getTextFromEditor (){
30
+ switchToEditArea ();
31
+ String text = driver .findElement (textArea ).getText ();
32
+ switchToMainArea ();
33
+ return text ;
34
+ }
35
+
36
+ public void decreaseIndention (){
37
+ driver .findElement (decreaseIndentButton ).click ();
38
+ }
39
+
40
+ private void switchToEditArea (){
41
+ driver .switchTo ().frame (editorIframeId );
42
+ }
43
+
44
+ private void switchToMainArea (){
45
+ driver .switchTo ().parentFrame ();
46
+ }
47
+ }
Original file line number Diff line number Diff line change
1
+ package frames ;
2
+
3
+ import base .BaseTests ;
4
+ import org .testng .annotations .Test ;
5
+
6
+ import static org .testng .Assert .assertEquals ;
7
+
8
+ public class FrameTests extends BaseTests {
9
+
10
+ @ Test
11
+ public void testWysiwyg (){
12
+ var editorPage = homePage .clickWysiwygEditor ();
13
+ editorPage .clearTextArea ();
14
+
15
+ String text1 = "hello " ;
16
+ String text2 = "world" ;
17
+
18
+ editorPage .setTextArea (text1 );
19
+ editorPage .decreaseIndention ();
20
+ editorPage .setTextArea (text2 );
21
+
22
+ assertEquals (editorPage .getTextFromEditor (), text1 +text2 , "Text from editor is incorrect" );
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments