use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.
the class HTMLOptionElement2Test method click2.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts(DEFAULT = "opt-a; opt-b", CHROME = "opt-b")
@BuggyWebDriver("opt-a; b;")
@NotYetImplemented
public // what happens when running the test manually in the browser.
void click2() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html><head><title>foo</title><script>\n" + " function log(x) {\n" + " document.getElementById('log_').value += x + '; ';\n" + " }\n" + " function init() {\n" + " s = document.getElementById('s');\n" + " s.addEventListener('click', handle, false);\n" + " }\n" + " function handle(event) {\n" + " log(s.options[s.selectedIndex].value);\n" + " }\n" + "</script></head>\n" + "<body onload='init()'>\n" + "<form>\n" + " <textarea id='log_' rows='4' cols='50'></textarea>\n" + " <select id='s'>\n" + " <option value='opt-a'>A</option>\n" + " <option id='opt-b' value='b'>B</option>\n" + " <option value='opt-c'>C</option>\n" + " </select>\n" + "</form>\n" + "</body></html>";
final WebDriver driver = loadPage2(html);
driver.findElement(By.id("s")).click();
driver.findElement(By.id("opt-b")).click();
final List<String> alerts = new LinkedList<>();
final WebElement log = driver.findElement(By.id("log_"));
alerts.add(log.getAttribute("value").trim());
assertEquals(getExpectedAlerts(), alerts);
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.
the class KeyboardEventTest method which.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts(DEFAULT = { "keydown:16,0,16,Shift,undefined,ShiftLeft,true", "keydown:65,0,65,A,undefined,KeyA,true", "keypress:65,65,65,A,undefined,KeyA,true", "keyup:65,0,65,A,undefined,KeyA,true", "keyup:16,0,16,Shift,undefined,ShiftLeft,false", "keydown:65,0,65,a,undefined,KeyA,false", "keypress:97,97,97,a,undefined,KeyA,false", "keyup:65,0,65,a,undefined,KeyA,false", "keydown:190,0,190,.,undefined,Period,false", "keypress:46,46,46,.,undefined,Period,false", "keyup:190,0,190,.,undefined,Period,false", "keydown:13,0,13,Enter,undefined,Enter,false", "keypress:13,13,13,Enter,undefined,Enter,false", "keyup:13,0,13,Enter,undefined,Enter,false" }, IE = { "keydown:16,0,16,Shift,,undefined,true", "keydown:65,0,65,A,A,undefined,true", "keypress:65,65,65,A,A,undefined,true", "keyup:65,0,65,A,A,undefined,true", "keyup:16,0,16,Shift,,undefined,false", "keydown:65,0,65,a,a,undefined,false", "keypress:97,97,97,a,a,undefined,false", "keyup:65,0,65,a,a,undefined,false", "keydown:190,0,190,.,.,undefined,false", "keypress:46,46,46,.,.,undefined,false", "keyup:190,0,190,.,.,undefined,false", "keydown:13,0,13,Enter,\\n,undefined,false", "keypress:13,13,13,Enter,\\n,undefined,false", "keyup:13,0,13,Enter,\\n,undefined,false" })
// https://github.com/SeleniumHQ/selenium/issues/2531
@BuggyWebDriver(CHROME = { "keydown:16,0,16,Shift,undefined,ShiftLeft,false", "keydown:65,0,65,A,undefined,KeyA,true", "keypress:65,65,65,A,undefined,KeyA,true", "keyup:65,0,65,A,undefined,KeyA,true", "keyup:16,0,16,Shift,undefined,ShiftLeft,false", "keydown:65,0,65,a,undefined,KeyA,false", "keypress:97,97,97,a,undefined,KeyA,false", "keyup:65,0,65,a,undefined,KeyA,false", "keydown:190,0,190,.,undefined,Period,false", "keypress:46,46,46,.,undefined,Period,false", "keyup:190,0,190,.,undefined,Period,false", "keydown:13,0,13,Enter,undefined,Enter,false", "keypress:13,13,13,Enter,undefined,Enter,false", "keyup:13,0,13,Enter,undefined,Enter,false" }, EDGE = { "keydown:16,0,16,Shift,undefined,ShiftLeft,false", "keydown:65,0,65,A,undefined,KeyA,true", "keypress:65,65,65,A,undefined,KeyA,true", "keyup:65,0,65,A,undefined,KeyA,true", "keyup:16,0,16,Shift,undefined,ShiftLeft,false", "keydown:65,0,65,a,undefined,KeyA,false", "keypress:97,97,97,a,undefined,KeyA,false", "keyup:65,0,65,a,undefined,KeyA,false", "keydown:190,0,190,.,undefined,Period,false", "keypress:46,46,46,.,undefined,Period,false", "keyup:190,0,190,.,undefined,Period,false", "keydown:13,0,13,Enter,undefined,Enter,false", "keypress:13,13,13,Enter,undefined,Enter,false", "keyup:13,0,13,Enter,undefined,Enter,false" }, FF_ESR = { "keydown:65,0,65,A,undefined,,false", "keypress:65,65,65,A,undefined,,false", "keyup:65,0,65,A,undefined,,false", "keydown:65,0,65,a,undefined,,false", "keypress:97,97,97,a,undefined,,false", "keyup:65,0,65,a,undefined,,false", "keydown:190,0,190,.,undefined,,false", "keypress:46,46,46,.,undefined,,false", "keyup:190,0,190,.,undefined,,false", "keydown:13,0,13,Enter,undefined,,false", "keypress:13,13,13,Enter,undefined,,false", "keyup:13,0,13,Enter,undefined,,false" }, FF = { "keydown:65,0,65,A,undefined,,false", "keypress:65,65,65,A,undefined,,false", "keyup:65,0,65,A,undefined,,false", "keydown:65,0,65,a,undefined,,false", "keypress:97,97,97,a,undefined,,false", "keyup:65,0,65,a,undefined,,false", "keydown:190,0,190,.,undefined,,false", "keypress:46,46,46,.,undefined,,false", "keyup:190,0,190,.,undefined,,false", "keydown:13,0,13,Enter,undefined,,false", "keypress:13,13,13,Enter,undefined,,false", "keyup:13,0,13,Enter,undefined,,false" }, IE = { "keydown:16,0,16,Shift,,undefined,false", "keydown:65,0,65,A,A,undefined,false", "keypress:65,65,65,A,A,undefined,false", "keyup:65,0,65,a,a,undefined,false", "keyup:16,0,16,Shift,,undefined,false", "keydown:65,0,65,a,a,undefined,false", "keypress:97,97,97,a,a,undefined,false", "keyup:65,0,65,a,a,undefined,false", "keydown:190,0,190,.,.,undefined,false", "keypress:46,46,46,.,.,undefined,false", "keyup:190,0,190,.,.,undefined,false", "keydown:13,0,13,Enter,\\n,undefined,false", "keypress:13,13,13,\\r,\\r,undefined,false", "keyup:13,0,13,Enter,\\n,undefined,false" })
public void which() throws Exception {
final String html = "<html><head></head><body>\n" + "<input type='text' id='keyId'>\n" + "<script>\n" + "function handler(e) {\n" + " e = e ? e : window.event;\n" + " var log = e.type + ':' + e.keyCode + ',' + e.charCode + ',' + e.which + ',' " + "+ e.key + ',' + e.char + ',' + e.code + ',' + e.shiftKey;\n" + " log = log.replace(/\\r/g, '\\\\r');\n" + " log = log.replace(/\\n/g, '\\\\n');\n" + " document.getElementById('myTextarea').value += log + '\\n';" + "}\n" + "document.getElementById('keyId').onkeyup = handler;\n" + "document.getElementById('keyId').onkeydown = handler;\n" + "document.getElementById('keyId').onkeypress = handler;\n" + "</script>\n" + "<textarea id='myTextarea' cols=80 rows=20></textarea>\n" + "</body></html>";
final String keysToSend = "Aa." + Keys.RETURN;
final WebDriver driver = loadPage2(html);
driver.findElement(By.id("keyId")).sendKeys(keysToSend);
final String[] actual = driver.findElement(By.id("myTextarea")).getAttribute("value").split("\n");
assertEquals(Arrays.asList(getExpectedAlerts()).toString(), Arrays.asList(actual).toString());
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.
the class HtmlAreaTest method referer.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts("§§URL§§")
@BuggyWebDriver(FF = "WebDriverException", FF_ESR = "WebDriverException", IE = "WebDriverException")
public void referer() throws Exception {
expandExpectedAlertsVariables(URL_FIRST);
final WebDriver driver = createWebClient("");
driver.get(URL_FIRST.toExternalForm());
try {
driver.findElement(By.id("third")).click();
final Map<String, String> lastAdditionalHeaders = getMockWebConnection().getLastAdditionalHeaders();
assertEquals(getExpectedAlerts()[0], lastAdditionalHeaders.get(HttpHeader.REFERER));
} catch (final WebDriverException e) {
e.printStackTrace();
assertEquals(getExpectedAlerts()[0], "WebDriverException");
}
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.
the class HtmlAreaTest method click_javascriptUrlLeadingWhitespace.
/**
* @throws Exception if the test fails
*/
@Test
@Alerts("clicked")
@BuggyWebDriver(FF = "Todo", FF_ESR = "Todo")
public void click_javascriptUrlLeadingWhitespace() throws Exception {
try (InputStream is = getClass().getClassLoader().getResourceAsStream("testfiles/tiny-jpg.img")) {
final byte[] directBytes = IOUtils.toByteArray(is);
final URL urlImage = new URL(URL_FIRST, "img.jpg");
final List<NameValuePair> emptyList = Collections.emptyList();
getMockWebConnection().setResponse(urlImage, directBytes, 200, "ok", "image/jpg", emptyList);
}
final String html = "<html><head><title>foo</title></head><body>\n" + "<img src='img.jpg' width='145' height='126' usemap='#somename'>\n" + "<map name='somename'>\n" + " <area href=' javascript:alert(\"clicked\")' id='a2' shape='rect' coords='0,0,30,30'/>\n" + "</map></body></html>";
final WebDriver driver = loadPage2(html);
final Page page;
if (driver instanceof HtmlUnitDriver) {
page = getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
} else {
page = null;
}
verifyAlerts(driver);
driver.findElement(By.id("a2")).click();
verifyAlerts(driver, getExpectedAlerts());
if (driver instanceof HtmlUnitDriver) {
final Page secondPage = getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage();
assertSame(page, secondPage);
}
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.
the class HtmlElement2Test method typeAtEndOfEditableDivWithParagraphInside.
/**
* @throws Exception if an error occurs
*/
@Test
@Alerts("Hello-world")
@BuggyWebDriver(FF = "-worldHello", FF_ESR = "-worldHello")
public void typeAtEndOfEditableDivWithParagraphInside() throws Exception {
final String html = "<html><head><script>\n" + " function test() {\n" + " alert(document.getElementById('myInput').value);\n" + " }\n" + "</script></head>\n" + "<body>\n" + " <input id='myButton' type='button' onclick='test()'>\n" + " <div id='myInput' contenteditable='true'><p>Hello</p></div>\n" + "</body></html>";
final WebDriver driver = loadPage2(html);
final WebElement div = driver.findElement(By.id("myInput"));
div.sendKeys("-world");
assertEquals(getExpectedAlerts()[0], div.getText());
}
Aggregations