Search in sources :

Example 31 with BuggyWebDriver

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

the class HtmlOption2Test method onMouse.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts(DEFAULT = "oDown,sDown,dDown,oUp,sUp,dUp,", IE = "sDown,dDown,sUp,dUp,")
// manual test are showing something different
@BuggyWebDriver(CHROME = "sUp,dUp,", EDGE = "sUp,dUp,", FF = "sDown,dDown,sUp,dUp,", FF_ESR = "sDown,dDown,sUp,dUp,")
public void onMouse() throws Exception {
    final String html = "<html><head><title>foo</title>\n" + "<script>\n" + "  function debug(string) {\n" + "    document.getElementById('myTextarea').value += string + ',';\n" + "  }\n" + "</script>\n" + "</head><body>\n" + "  <form>\n" + "    <div" + " onMouseDown='debug(\"dDown\");'" + " onMouseUp='debug(\"dUp\");'>\n" + "    <select name='select1' size='4'" + " onMouseDown='debug(\"sDown\");'" + " onMouseUp='debug(\"sUp\");'>\n" + "      <option id='opt1' value='option1'>Option1</option>\n" + "      <option id='opt2' value='option2' selected='selected'>Option2</option>\n" + "      <option id='opt3' value='option3'" + " onMouseDown='debug(\"oDown\");'" + " onMouseUp='debug(\"oUp\");'>Option3</option>\n" + "    </select>\n" + "    </div>\n" + "  </form>\n" + "  <textarea id='myTextarea'></textarea>\n" + "</body></html>";
    final WebDriver driver = loadPage2(html);
    driver.findElement(By.id("opt3")).click();
    assertEquals(Arrays.asList(getExpectedAlerts()).toString(), '[' + driver.findElement(By.id("myTextarea")).getAttribute("value") + ']');
}
Also used : WebDriver(org.openqa.selenium.WebDriver) BuggyWebDriver(com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver) Test(org.junit.Test) BuggyWebDriver(com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver) Alerts(com.gargoylesoftware.htmlunit.junit.BrowserRunner.Alerts)

Example 32 with BuggyWebDriver

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

the class HTMLSelectElementTest method mouseOverDisabledSelect.

/**
 * @throws Exception if an error occurs
 */
@Test
@Alerts(DEFAULT = "", FF = "mouse over", FF_ESR = "mouse over")
@BuggyWebDriver(FF = "mouse overmouse overmouse over", FF_ESR = "mouse overmouse overmouse over")
public void mouseOverDisabledSelect() throws Exception {
    final String html = "<html>\n" + "  <head>\n" + "    <script>\n" + "    function doTest() {\n" + "      document.title += 'mouse over';\n" + "    }\n" + "    </script>\n" + "  </head>\n" + "<body>\n" + "  <form id='form1'>\n" + "    <select name='select1' id='select1' size='4' onmouseover='doTest()' disabled='disabled'>\n" + "      <option value='option1' id='option1'>Option1</option>\n" + "      <option value='option2' id='option2'>Option2</option>\n" + "    </select>\n" + "  </form>\n" + "</body></html>";
    final WebDriver driver = loadPage2(html);
    final Actions actions = new Actions(driver);
    actions.moveToElement(driver.findElement(By.id("select1")));
    actions.perform();
    Thread.sleep(400);
    assertTitle(driver, getExpectedAlerts()[0]);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) BuggyWebDriver(com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver) Actions(org.openqa.selenium.interactions.Actions) 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 33 with BuggyWebDriver

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

the class HTMLSelectElementTest method mouseOver.

/**
 * @throws Exception if an error occurs
 */
@Test
@Alerts("mouse over")
@BuggyWebDriver(FF = "mouse overmouse overmouse over", FF_ESR = "mouse overmouse overmouse over")
public void mouseOver() throws Exception {
    final String html = "<html>\n" + "  <head>\n" + "    <script>\n" + "    function doTest() {\n" + "      document.title += 'mouse over';\n" + "    }\n" + "    </script>\n" + "  </head>\n" + "<body>\n" + "  <form id='form1'>\n" + "    <select name='select1' id='select1' size='4' onmouseover='doTest()'>\n" + "      <option value='option1' id='option1' >Option1</option>\n" + "      <option value='option2' id='option2'>Option2</option>\n" + "    </select>\n" + "  </form>\n" + "</body></html>";
    final WebDriver driver = loadPage2(html);
    final Actions actions = new Actions(driver);
    actions.moveToElement(driver.findElement(By.id("select1")));
    actions.perform();
    Thread.sleep(400);
    assertTitle(driver, getExpectedAlerts()[0]);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) BuggyWebDriver(com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver) Actions(org.openqa.selenium.interactions.Actions) 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 34 with BuggyWebDriver

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

the class HTMLOptionElement2Test method clickSelect.

/**
 * @throws Exception if the test fails
 */
@Test
@Alerts("SELECT;")
@BuggyWebDriver(CHROME = "", EDGE = "")
public // https://bugs.chromium.org/p/chromedriver/issues/detail?id=1352
void clickSelect() 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" + "    var s = document.getElementById('s');\n" + "    s.addEventListener('click', handle, false);\n" + "  }\n" + "  function handle(event) {\n" + "    if (event.target) {\n" + "      log(event.target.nodeName);\n" + "    } else {\n" + "      log(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='7'>\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();
    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 35 with BuggyWebDriver

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

the class HTMLOptionElement2Test method clickOptionEventSequence2.

/**
 * Test for the right event sequence when clicking.
 *
 * @throws Exception if the test fails
 */
@Test
@Alerts(DEFAULT = "change-SELECT; click-OPTION; click-OPTION;", IE = "change-SELECT; click-SELECT;")
@BuggyWebDriver(CHROME = "change-SELECT; click-SELECT;", EDGE = "change-SELECT; click-SELECT;", FF = "change-SELECT; click-SELECT;", FF_ESR = "change-SELECT; click-SELECT;")
public void clickOptionEventSequence2() 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' >\n" + "    <option id='clickId' value='a' >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)

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