use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.
the class HTMLDocumentTest method readyState.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts(DEFAULT = "complete,[object HTMLBodyElement]-complete,[object HTMLBodyElement]-", FF = "uninitialized,[object HTMLBodyElement]-uninitialized,[object HTMLBodyElement]-", FF_ESR = "uninitialized,[object HTMLBodyElement]-uninitialized,[object HTMLBodyElement]-", IE = "loading,[object HTMLBodyElement]-complete,[object HTMLBodyElement]-")
@HtmlUnitNYI(CHROME = "loading,[object HTMLBodyElement]-complete,[object HTMLBodyElement]-", EDGE = "loading,[object HTMLBodyElement]-complete,[object HTMLBodyElement]-", FF = "loading,[object HTMLBodyElement]-complete,[object HTMLBodyElement]-", FF_ESR = "loading,[object HTMLBodyElement]-complete,[object HTMLBodyElement]-")
public void readyState() throws Exception {
final String html = "<html>\n" + "<head>\n" + " <script>\n" + " var doc;\n" + " function test() {\n" + " var iframe = document.createElement('iframe');\n" + " var textarea = document.getElementById('myTextarea');\n" + " textarea.parentNode.appendChild(iframe);\n" + " doc = iframe.contentWindow.document;\n" + " check();\n" + " setTimeout(check, 100);\n" + " }\n" + " function check() {\n" + " var textarea = document.getElementById('myTextarea');\n" + " textarea.value += doc.readyState + ',' + doc.body + '-';\n" + " }\n" + " </script>\n" + "</head>\n" + "<body onload='test()'>\n" + "<div>\n" + " <textarea id='myTextarea' cols='80'></textarea>\n" + "</div>\n" + "</body>\n" + "</html>";
final WebDriver driver = loadPage2(html);
Thread.sleep(200);
final List<String> actual = new LinkedList<>();
actual.add(driver.findElement(By.id("myTextarea")).getAttribute("value"));
assertEquals(getExpectedAlerts(), actual);
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.
the class SvgScriptTest method htmlOrSvg.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts({ "[object SVGScriptElement]", "[object HTMLScriptElement]" })
@HtmlUnitNYI(CHROME = { "[object SVGScriptElement]", "[object SVGScriptElement]" }, EDGE = { "[object SVGScriptElement]", "[object SVGScriptElement]" }, FF = { "[object SVGScriptElement]", "[object SVGScriptElement]" }, FF_ESR = { "[object SVGScriptElement]", "[object SVGScriptElement]" }, IE = { "[object SVGScriptElement]", "[object SVGScriptElement]" })
public void htmlOrSvg() throws Exception {
final String html = "<svg xmlns='http://www.w3.org/2000/svg' version='1.1'>\n" + "<script id='id1'>\n" + LOG_TITLE_FUNCTION + " function test() {\n" + " log(document.getElementById('id1'));\n" + " log(document.getElementById('id2'));\n" + " }\n" + "</script>\n" + "<body onload='test()'>\n" + " <script id='id2'></script>\n" + "</body>\n" + "</svg>";
final WebDriver driver = loadPageVerifyTitle2(html);
if (driver instanceof HtmlUnitDriver) {
final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
assertType(getExpectedAlerts()[0], page.getElementById("id1"));
assertType(getExpectedAlerts()[1], page.getElementById("id2"));
}
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.
the class HtmlLabelTest method clickForInput.
/**
* @throws Exception if an error occurs
*/
@Test
@Alerts(DEFAULT = { "labelclick", "textfocus", "textclick" }, IE = { "labelclick", "textclick", "textfocus" })
@HtmlUnitNYI(IE = { "labelclick", "textfocus", "textclick" })
public void clickForInput() throws Exception {
final String html = " <label id='label1' for='text1' onclick='log(\"labelclick\")' " + "onfocus='log(\"labelfocus\")'>Click me</label>\n" + " <input type='text' id='text1' onclick='log(\"textclick\")' " + "onfocus='log(\"textfocus\")'>\n";
final WebDriver driver = loadPage2(generatePage(html));
driver.findElement(By.id("label1")).click();
verifyTitle2(driver, getExpectedAlerts());
assertEquals(driver.findElement(By.id("text1")), driver.switchTo().activeElement());
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.
the class HtmlOption2Test method getVisibleText.
/**
* Verifies getVisibleText().
* @throws Exception if the test fails
*/
@Test
@Alerts(DEFAULT = { "option1", "", "Number Three", "Number 4", "option1\nNumber Three\nNumber 4" }, CHROME = { "option1", "", "Number Three", "Number 4", " option1\n Number Three\n Number 4\n " }, EDGE = { "option1", "", "Number Three", "Number 4", " option1\n Number Three\n Number 4\n " }, IE = { "option1", "", "Number Three", "Number 4", "option1 Number Three Number 4" })
@HtmlUnitNYI(CHROME = { "option1", "", "Number Three", "Number 4", "option1\nNumber Three\nNumber 4" }, EDGE = { "option1", "", "Number Three", "Number 4", "option1\nNumber Three\nNumber 4" }, IE = { "option1", "", "Number Three", "Number 4", "option1\nNumber Three\nNumber 4" })
public void getVisibleText() throws Exception {
final String htmlContent = "<html>\n" + "<head></head>\n" + "<body id='tester'>\n" + " <form>\n" + " <select>\n" + " <option id='option1'>option1</option>\n" + " <option id='option2' label='Number Two'/>\n" + " <option id='option3' label='overridden'>Number Three</option>\n" + " <option id='option4'>Number 4</option>\n" + " </select>\n" + " </form>\n" + "</body></html>";
final WebDriver driver = loadPage2(htmlContent);
String text = driver.findElement(By.id("option1")).getText();
assertEquals(getExpectedAlerts()[0], text);
text = driver.findElement(By.id("option2")).getText();
assertEquals(getExpectedAlerts()[1], text);
text = driver.findElement(By.id("option3")).getText();
assertEquals(getExpectedAlerts()[2], text);
text = driver.findElement(By.id("option4")).getText();
assertEquals(getExpectedAlerts()[3], text);
text = driver.findElement(By.id("tester")).getText();
assertEquals(getExpectedAlerts()[4], text);
if (driver instanceof HtmlUnitDriver) {
final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
assertEquals(getExpectedAlerts()[4], page.getElementById("tester").getVisibleText());
}
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI in project htmlunit by HtmlUnit.
the class HtmlNumberInputTest method typeIntegerNegativeValid.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts(DEFAULT = { "", "--null-false", "-12", "-12--null-true", "-123", "-123--null-false" }, IE = { "", "--null-true", "12", "12--null-true", "123", "123--null-true" })
@HtmlUnitNYI(CHROME = { "-", "--null-false", "-12", "-12--null-true", "-123", "-123--null-false" }, EDGE = { "-", "--null-false", "-12", "-12--null-true", "-123", "-123--null-false" }, FF = { "-", "--null-false", "-12", "-12--null-true", "-123", "-123--null-false" }, FF_ESR = { "-", "--null-false", "-12", "-12--null-true", "-123", "-123--null-false" }, IE = { "-", "--null-false", "-12", "-12--null-true", "-123", "-123--null-false" })
public void typeIntegerNegativeValid() throws Exception {
final String html = "<html>\n" + "<head>\n" + "<script>\n" + " function test() {\n" + " var input = document.getElementById('inpt');\n" + " document.title = input.value + '-' " + "+ input.defaultValue + '-' " + "+ input.getAttribute('value')+ '-' " + "+ input.checkValidity();\n" + " }\n" + "</script>\n" + "</head>\n" + "<body>\n" + " <input type='number' id='inpt' min='-42' max='1234'/>\n" + " <button id='check' onclick='test()');'>" + "DoIt</button>\n" + "</body>\n" + "</html>";
final WebDriver driver = loadPage2(html);
final WebElement input = driver.findElement(By.id("inpt"));
final WebElement check = driver.findElement(By.id("check"));
input.sendKeys("-");
assertEquals(getExpectedAlerts()[0], input.getAttribute("value"));
check.click();
assertEquals(getExpectedAlerts()[1], driver.getTitle());
input.sendKeys("12");
assertEquals(getExpectedAlerts()[2], input.getAttribute("value"));
check.click();
assertEquals(getExpectedAlerts()[3], driver.getTitle());
input.sendKeys("3");
assertEquals(getExpectedAlerts()[4], input.getAttribute("value"));
check.click();
assertEquals(getExpectedAlerts()[5], driver.getTitle());
}
Aggregations