Search in sources :

Example 6 with BuggyWebDriver

use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.

the class HTMLOptionElement2Test method clickOptionEventSequence1.

/**
 * Test for the right event sequence when clicking.
 *
 * @throws Exception if the test fails
 */
@Test
@Alerts(DEFAULT = "onchange-select; onclick-option; onclick-select;", IE = "onchange-select; onclick-select;")
@BuggyWebDriver(CHROME = "onchange-select; onclick-select;", EDGE = "onchange-select; onclick-select;", FF = "onchange-select; onclick-select;", FF_ESR = "onchange-select; onclick-select;")
public void clickOptionEventSequence1() throws Exception {
    final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html><head>\n" + "<script>\n" + "  function log(x) {\n" + "    document.getElementById('log_').value += x + '; ';\n" + "  }\n" + "</script></head>\n" + "<body>\n" + "<form>\n" + "  <textarea id='log_' rows='4' cols='50'></textarea>\n" + "  <select id='s' size='2' onclick=\"log('onclick-select')\"" + " onchange=\"log('onchange-select')\">\n" + "    <option id='clickId' value='a' onclick=\"log('onclick-option')\"" + " onchange=\"log('onchange-option')\">A</option>\n" + "  </select>\n" + "</form>\n" + "</body></html>";
    final WebDriver driver = loadPage2(html);
    driver.findElement(By.id("clickId")).click();
    final List<String> alerts = new LinkedList<>();
    final WebElement log = driver.findElement(By.id("log_"));
    alerts.add(log.getAttribute("value").trim());
    assertEquals(getExpectedAlerts(), alerts);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) BuggyWebDriver(com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver) WebElement(org.openqa.selenium.WebElement) LinkedList(java.util.LinkedList) HtmlPageTest(com.gargoylesoftware.htmlunit.html.HtmlPageTest) Test(org.junit.Test) BuggyWebDriver(com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 7 with BuggyWebDriver

use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.

the class HTMLOptionElement2Test method clickOptionEventSequence3.

/**
 * Test for the right event sequence when clicking.
 *
 * @throws Exception if the test fails
 */
@Test
@Alerts(DEFAULT = "onchange-select; change-SELECT; onclick-option; click-OPTION; onclick-select; click-OPTION;", IE = "onchange-select; change-SELECT; onclick-select; click-SELECT;")
@BuggyWebDriver(CHROME = "onchange-select; change-SELECT; onclick-select; click-SELECT;", EDGE = "onchange-select; change-SELECT; onclick-select; click-SELECT;", FF = "onchange-select; change-SELECT; onclick-select; click-SELECT;", FF_ESR = "onchange-select; change-SELECT; onclick-select; click-SELECT;")
public void clickOptionEventSequence3() throws Exception {
    final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html><head>\n" + "<script>\n" + "  function log(x) {\n" + "    document.getElementById('log_').value += x + '; ';\n" + "  }\n" + "  function init() {\n" + "    var s = document.getElementById('s');\n" + "    var o = document.getElementById('clickId');\n" + "    s.addEventListener('click', handle, false);\n" + "    s.addEventListener('change', handle, false);\n" + "    o.addEventListener('click', handle, false);\n" + "    o.addEventListener('change', handle, false);\n" + "  }\n" + "  function handle(event) {\n" + "    if (event.target) {\n" + "      log(event.type + '-' + event.target.nodeName);\n" + "    } else {\n" + "      log(event.type + '-' + event.srcElement.nodeName);\n" + "    }\n" + "  }\n" + "</script></head>\n" + "<body onload='init()'>\n" + "<form>\n" + "  <textarea id='log_' rows='4' cols='50'></textarea>\n" + "  <select id='s' size='2' onclick=\"log('onclick-select')\"" + " onchange=\"log('onchange-select')\">\n" + "    <option id='clickId' value='a' onclick=\"log('onclick-option')\"" + " onchange=\"log('onchange-option')\">A</option>\n" + "  </select>\n" + "</form>\n" + "</body></html>";
    final WebDriver driver = loadPage2(html);
    driver.findElement(By.id("clickId")).click();
    final List<String> alerts = new LinkedList<>();
    final WebElement log = driver.findElement(By.id("log_"));
    alerts.add(log.getAttribute("value").trim());
    assertEquals(getExpectedAlerts(), alerts);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) BuggyWebDriver(com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver) WebElement(org.openqa.selenium.WebElement) LinkedList(java.util.LinkedList) HtmlPageTest(com.gargoylesoftware.htmlunit.html.HtmlPageTest) Test(org.junit.Test) BuggyWebDriver(com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 8 with BuggyWebDriver

use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.

the class HtmlElement2Test method typeAtEndOfEditableDiv.

/**
 * @throws Exception if an error occurs
 */
@Test
@Alerts("Hello-world")
@BuggyWebDriver(FF = "-worldHello", FF_ESR = "-worldHello")
public void typeAtEndOfEditableDiv() 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'>Hello</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());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) BuggyWebDriver(com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) BuggyWebDriver(com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 9 with BuggyWebDriver

use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.

the class HtmlElement2Test method shiftKeys.

/**
 * @throws Exception if an error occurs
 */
@Test
// to test this manually you have to use an english keyboard layout
@Alerts("down: 16,0 down: 49,0 press: 33,33 up: 49,0 up: 16,0" + " down: 16,0 down: 220,0 press: 124,124 up: 220,0 up: 16,0")
// https://github.com/SeleniumHQ/selenium/issues/639
@BuggyWebDriver(FF_ESR = "down: 49,0 press: 33,33 up: 49,0 down: 220,0 press: 124,124 up: 220,0", FF = "down: 49,0 press: 33,33 up: 49,0 down: 220,0 press: 124,124 up: 220,0")
public void shiftKeys() throws Exception {
    final String html = "<html><head><script>\n" + "  function appendMessage(message) {\n" + "    document.getElementById('result').innerHTML += message + ' ';\n" + "  }\n" + "</script></head>\n" + "<body >\n" + "  <input id='input1' onkeyup=\"appendMessage('up: ' + event.keyCode + ',' + event.charCode)\" " + "onkeypress=\"appendMessage('press: ' + event.keyCode + ',' + event.charCode)\" " + "onkeydown=\"appendMessage('down: ' + event.keyCode + ',' + event.charCode)\"><br>\n" + "<p id='result'></p>\n" + "</body></html>";
    final WebDriver driver = loadPage2(html);
    final WebElement input = driver.findElement(By.id("input1"));
    final WebElement result = driver.findElement(By.id("result"));
    input.sendKeys("!|");
    assertEquals(getExpectedAlerts()[0], result.getText());
}
Also used : WebDriver(org.openqa.selenium.WebDriver) BuggyWebDriver(com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test) BuggyWebDriver(com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 10 with BuggyWebDriver

use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.

the class HTMLIFrameElement3Test method recursiveContentRedirectHeader.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts(DEFAULT = { "loaded", "6" }, FF_ESR = { "loaded", "19" }, FF = { "loaded", "19" }, IE = { "loaded", "2" })
@BuggyWebDriver(IE = "")
// this kill the real ie
@HtmlUnitNYI(CHROME = { "loaded", "21" }, EDGE = { "loaded", "21" }, FF = { "loaded", "21" }, FF_ESR = { "loaded", "21" }, IE = { "loaded", "21" })
public void recursiveContentRedirectHeader() throws Exception {
    final String html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "  <title>Deny</title>\n" + "</head>\n" + "<body>\n" + "  <iframe id='frame1' src='content.html' " + "onLoad='alert(\"loaded\")'></iframe>\n" + "</body>\n" + "</html>";
    final String content = "<html>" + "<head><title>IFrame Title</title></head>\n" + "<body>IFrame Content\n" + "  <iframe id='frame1' src='content.html'></iframe>\n" + "</body>\n" + "</html>";
    getMockWebConnection().setDefaultResponse(content);
    final List<NameValuePair> headers = new ArrayList<>();
    headers.add(new NameValuePair("Location", "content2.html"));
    getMockWebConnection().setResponse(new URL(URL_FIRST, "content.html"), "", 302, "Moved", MimeType.TEXT_HTML, headers);
    final String[] expectedAlerts = getExpectedAlerts();
    setExpectedAlerts(Arrays.copyOf(expectedAlerts, 1));
    loadPageWithAlerts2(html);
    assertEquals(Integer.parseInt(expectedAlerts[1]), getMockWebConnection().getRequestCount());
}
Also used : NameValuePair(com.gargoylesoftware.htmlunit.util.NameValuePair) ArrayList(java.util.ArrayList) URL(java.net.URL) HtmlPageTest(com.gargoylesoftware.htmlunit.html.HtmlPageTest) Test(org.junit.Test) BuggyWebDriver(com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts) HtmlUnitNYI(com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI)

Aggregations

BuggyWebDriver (com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver)43 Test (org.junit.Test)42 WebDriver (org.openqa.selenium.WebDriver)41 Alerts (com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)35 WebElement (org.openqa.selenium.WebElement)15 HtmlPageTest (com.gargoylesoftware.htmlunit.html.HtmlPageTest)11 Actions (org.openqa.selenium.interactions.Actions)8 LogEntries (org.openqa.selenium.logging.LogEntries)8 LogEntry (org.openqa.selenium.logging.LogEntry)8 Logs (org.openqa.selenium.logging.Logs)8 URL (java.net.URL)7 NameValuePair (com.gargoylesoftware.htmlunit.util.NameValuePair)6 LinkedList (java.util.LinkedList)5 HtmlUnitDriver (org.openqa.selenium.htmlunit.HtmlUnitDriver)5 NotYetImplemented (com.gargoylesoftware.htmlunit.junit.BrowserRunner.NotYetImplemented)4 InputStream (java.io.InputStream)4 Page (com.gargoylesoftware.htmlunit.Page)3 Action (org.openqa.selenium.interactions.Action)3 HtmlUnitNYI (com.gargoylesoftware.htmlunit.junit.BrowserRunner.HtmlUnitNYI)2 MockWebConnection (com.gargoylesoftware.htmlunit.MockWebConnection)1