| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.test.ui.po.editor.wysiwyg; |
| 21 |
|
|
| 22 |
|
import org.openqa.selenium.JavascriptExecutor; |
| 23 |
|
import org.openqa.selenium.WebDriver; |
| 24 |
|
import org.openqa.selenium.WebElement; |
| 25 |
|
import org.xwiki.test.ui.po.BaseElement; |
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
@version |
| 31 |
|
@since |
| 32 |
|
|
| |
|
| 79.5% |
Uncovered Elements: 8 (39) |
Complexity: 10 |
Complexity Density: 0.36 |
|
| 33 |
|
public class RichTextAreaElement extends BaseElement |
| 34 |
|
{ |
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
private final WebElement iframe; |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
@param |
| 44 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 45 |
22 |
public RichTextAreaElement(WebElement iframe)... |
| 46 |
|
{ |
| 47 |
22 |
this.iframe = iframe; |
| 48 |
|
} |
| 49 |
|
|
| 50 |
|
|
| 51 |
|
@return |
| 52 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 53 |
13 |
public String getText()... |
| 54 |
|
{ |
| 55 |
13 |
String windowHandle = getDriver().getWindowHandle(); |
| 56 |
13 |
try { |
| 57 |
13 |
return getActiveElement().getText(); |
| 58 |
|
} finally { |
| 59 |
13 |
getDriver().switchTo().window(windowHandle); |
| 60 |
|
} |
| 61 |
|
} |
| 62 |
|
|
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 66 |
7 |
public void clear()... |
| 67 |
|
{ |
| 68 |
7 |
String windowHandle = getDriver().getWindowHandle(); |
| 69 |
7 |
try { |
| 70 |
7 |
getActiveElement().clear(); |
| 71 |
|
} finally { |
| 72 |
7 |
getDriver().switchTo().window(windowHandle); |
| 73 |
|
} |
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 79 |
0 |
public void click()... |
| 80 |
|
{ |
| 81 |
0 |
String windowHandle = getDriver().getWindowHandle(); |
| 82 |
0 |
try { |
| 83 |
0 |
getActiveElement().click(); |
| 84 |
|
} finally { |
| 85 |
0 |
getDriver().switchTo().window(windowHandle); |
| 86 |
|
} |
| 87 |
|
} |
| 88 |
|
|
| 89 |
|
|
| 90 |
|
|
| 91 |
|
|
| 92 |
|
@param |
| 93 |
|
|
| |
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 94 |
15 |
public void sendKeys(CharSequence... keysToSend)... |
| 95 |
|
{ |
| 96 |
15 |
if (keysToSend.length > 0) { |
| 97 |
15 |
String windowHandle = getDriver().getWindowHandle(); |
| 98 |
15 |
try { |
| 99 |
15 |
getActiveElement().sendKeys(keysToSend); |
| 100 |
|
} finally { |
| 101 |
15 |
getDriver().switchTo().window(windowHandle); |
| 102 |
|
} |
| 103 |
|
} |
| 104 |
|
} |
| 105 |
|
|
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| 109 |
|
@param |
| 110 |
|
@param |
| 111 |
|
@return |
| 112 |
|
@see |
| 113 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 114 |
2 |
public Object executeScript(String script, Object... arguments)... |
| 115 |
|
{ |
| 116 |
2 |
String windowHandle = getDriver().getWindowHandle(); |
| 117 |
2 |
try { |
| 118 |
2 |
getActiveElement(); |
| 119 |
2 |
return ((JavascriptExecutor) getDriver()).executeScript(script.toString(), arguments); |
| 120 |
|
} finally { |
| 121 |
2 |
getDriver().switchTo().window(windowHandle); |
| 122 |
|
} |
| 123 |
|
} |
| 124 |
|
|
| 125 |
|
|
| 126 |
|
@return |
| 127 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 128 |
0 |
public String getContent()... |
| 129 |
|
{ |
| 130 |
0 |
return (String) executeScript("return document.body.innerHTML"); |
| 131 |
|
} |
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
| 136 |
|
@param |
| 137 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 138 |
2 |
public void setContent(String content)... |
| 139 |
|
{ |
| 140 |
2 |
executeScript("document.body.innerHTML = arguments[0];", content); |
| 141 |
|
} |
| 142 |
|
|
| 143 |
|
|
| 144 |
|
@return |
| 145 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 146 |
37 |
private WebElement getActiveElement()... |
| 147 |
|
{ |
| 148 |
|
|
| 149 |
|
|
| 150 |
|
|
| 151 |
|
|
| 152 |
|
|
| 153 |
37 |
WebDriver frameDriver = getDriver().switchTo().frame(iframe); |
| 154 |
|
|
| 155 |
|
|
| 156 |
37 |
WebDriver.TargetLocator locator = frameDriver.switchTo(); |
| 157 |
|
|
| 158 |
|
|
| 159 |
37 |
return locator.activeElement(); |
| 160 |
|
} |
| 161 |
|
} |