use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.
the class HtmlAnchorTest method ctrlClick.
/**
* @exception Exception If the test fails
*/
@Test
@Alerts({ "1", "First" })
@BuggyWebDriver(IE = { "0", "Second" })
public void ctrlClick() throws Exception {
final String html = "<html><head><title>First</title></head><body>\n" + "<a href='" + URL_SECOND + "'>Click Me</a>\n" + "</form></body></html>";
getMockWebConnection().setResponse(URL_SECOND, "<head><title>Second</title>");
final WebDriver driver = loadPage2(html);
final WebElement link = driver.findElement(By.linkText("Click Me"));
final int windowsSize = driver.getWindowHandles().size();
new Actions(driver).moveToElement(link).keyDown(Keys.CONTROL).click().keyUp(Keys.CONTROL).perform();
Thread.sleep(DEFAULT_WAIT_TIME);
assertEquals("Should have opened a new window", windowsSize + Integer.parseInt(getExpectedAlerts()[0]), driver.getWindowHandles().size());
assertEquals("Should not have navigated away", getExpectedAlerts()[1], driver.getTitle());
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.
the class HtmlSelect2Test method select.
/**
* @exception Exception If the test fails
*/
@Test
@Alerts({ "false", "false", "false", "true" })
@BuggyWebDriver(IE = { "false", "false", "true", "false" })
public void select() throws Exception {
final String html = "<html><head><title>foo</title></head><body>\n" + "<form id='form1'><select name='select1' multiple>\n" + " <option value='option1'>Option1</option>\n" + " <option value='option2'>Option2</option>\n" + " <option value='option3' selected='selected'>Option3</option>\n" + " <option value='option4'>Option4</option>\n" + "</select>\n" + "<input type='submit' name='button' value='foo'/>\n" + "</form></body></html>";
final WebDriver driver = loadPage2(html);
final List<WebElement> options = driver.findElements(By.tagName("option"));
final Actions actions = new Actions(driver);
final Action selectThreeOptions = actions.click(options.get(1)).click(options.get(2)).click(options.get(3)).build();
selectThreeOptions.perform();
assertEquals(Boolean.parseBoolean(getExpectedAlerts()[0]), options.get(0).isSelected());
assertEquals(Boolean.parseBoolean(getExpectedAlerts()[1]), options.get(1).isSelected());
assertEquals(Boolean.parseBoolean(getExpectedAlerts()[2]), options.get(2).isSelected());
assertEquals(Boolean.parseBoolean(getExpectedAlerts()[3]), options.get(3).isSelected());
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.
the class HtmlSelect2Test method controlClick.
/**
* @exception Exception If the test fails
*/
@Test
@Alerts({ "false", "true", "false", "true" })
@BuggyWebDriver(IE = { "false", "false", "true", "false" })
public void controlClick() throws Exception {
final String html = "<html><head><title>foo</title></head><body>\n" + "<form id='form1'><select name='select1' multiple>\n" + " <option value='option1'>Option1</option>\n" + " <option value='option2'>Option2</option>\n" + " <option value='option3' selected='selected'>Option3</option>\n" + " <option value='option4'>Option4</option>\n" + "</select>\n" + "<input type='submit' name='button' value='foo'/>\n" + "</form></body></html>";
final WebDriver driver = loadPage2(html);
final List<WebElement> options = driver.findElements(By.tagName("option"));
final Actions actions = new Actions(driver);
final Action selectThreeOptions = actions.click(options.get(1)).keyDown(Keys.CONTROL).click(options.get(3)).keyUp(Keys.CONTROL).build();
selectThreeOptions.perform();
assertEquals(Boolean.parseBoolean(getExpectedAlerts()[0]), options.get(0).isSelected());
assertEquals(Boolean.parseBoolean(getExpectedAlerts()[1]), options.get(1).isSelected());
assertEquals(Boolean.parseBoolean(getExpectedAlerts()[2]), options.get(2).isSelected());
assertEquals(Boolean.parseBoolean(getExpectedAlerts()[3]), options.get(3).isSelected());
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.
the class HtmlSelect2Test method shiftClick.
/**
* @exception Exception If the test fails
*/
@Test
@Alerts({ "false", "true", "true", "true" })
@BuggyWebDriver(IE = { "false", "false", "true", "false" })
public void shiftClick() throws Exception {
final String html = "<html><head><title>foo</title></head><body>\n" + "<form id='form1'><select name='select1' multiple>\n" + " <option value='option1'>Option1</option>\n" + " <option value='option2'>Option2</option>\n" + " <option value='option3' selected='selected'>Option3</option>\n" + " <option value='option4'>Option4</option>\n" + "</select>\n" + "<input type='submit' name='button' value='foo'/>\n" + "</form></body></html>";
final WebDriver driver = loadPage2(html);
final List<WebElement> options = driver.findElements(By.tagName("option"));
final Actions actions = new Actions(driver);
final Action selectThreeOptions = actions.click(options.get(1)).keyDown(Keys.SHIFT).click(options.get(3)).keyUp(Keys.SHIFT).build();
selectThreeOptions.perform();
assertEquals(Boolean.parseBoolean(getExpectedAlerts()[0]), options.get(0).isSelected());
assertEquals(Boolean.parseBoolean(getExpectedAlerts()[1]), options.get(1).isSelected());
assertEquals(Boolean.parseBoolean(getExpectedAlerts()[2]), options.get(2).isSelected());
assertEquals(Boolean.parseBoolean(getExpectedAlerts()[3]), options.get(3).isSelected());
}
use of com.gargoylesoftware.htmlunit.junit.BrowserRunner.BuggyWebDriver in project htmlunit by HtmlUnit.
the class ConsoleTest method assertObjects.
/**
* @throws Exception if the test fails
*/
@Test
@BuggyWebDriver
public void assertObjects() throws Exception {
final String html = "<html>\n" + "<body>\n" + "<script>\n" + " number = 1;\n" + " console.assert(number % 2 === 0, {number: number}, {errorMsg: 'the # is not even'});\n" + "</script>\n" + "</body></html>";
final WebDriver driver = loadPage2(html);
final Logs logs = driver.manage().logs();
final LogEntries logEntries = logs.get(LogType.BROWSER);
final List<LogEntry> logEntryList = logEntries.getAll();
assertEquals(1, logEntryList.size());
final LogEntry logEntry = logEntryList.get(0);
assertTrue(logEntry.getMessage(), logEntry.getMessage().contains("Assertion failed: ({number: 1.0}) ({errorMsg: \"the # is not even\"})"));
}
Aggregations