List of usage examples for org.openqa.selenium WebDriver getCurrentUrl
String getCurrentUrl();
From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchor2Test.java
License:Apache License
/** * @throws Exception if an error occurs// ww w .j av a2 s. c o m */ @Test public void clickNestedImageElement() throws Exception { final String html = "<html>\n" + "<body>\n" + " <a href='page2.html'>\n" + " <img id='theImage' src='test.png' />\n" + " </a>\n" + "</body></html>"; getMockWebConnection().setDefaultResponse(""); final WebDriver driver = loadPage2(html); final WebElement img = driver.findElement(By.id("theImage")); assertEquals("img", img.getTagName()); img.click(); assertEquals(new URL(getDefaultUrl(), "page2.html").toString(), driver.getCurrentUrl()); }
From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchor2Test.java
License:Apache License
/** * @throws Exception if an error occurs//from www. j a v a 2 s . c o m */ @Test @Alerts(DEFAULT = "page2.html", IE = "") public void clickNestedInputImageElement() throws Exception { final String html = "<html>\n" + "<body>\n" + " <a href='page2.html'>\n" + " <input type='image' id='theInput' />\n" + " </a>\n" + "</body></html>"; getMockWebConnection().setDefaultResponse(""); final WebDriver driver = loadPage2(html); final WebElement input = driver.findElement(By.id("theInput")); assertEquals("input", input.getTagName()); input.click(); assertEquals(new URL(getDefaultUrl(), getExpectedAlerts()[0]).toString(), driver.getCurrentUrl()); }
From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchor2Test.java
License:Apache License
/** * @throws Exception if an error occurs//from w ww.j av a2 s . co m */ @Test @Alerts(DEFAULT = "page2.html", IE = "") public void clickNestedInputTextElement() throws Exception { final String html = "<html>\n" + "<body>\n" + " <a href='page2.html'>\n" + " <input type='text' id='theInput' />\n" + " </a>\n" + "</body></html>"; getMockWebConnection().setDefaultResponse(""); final WebDriver driver = loadPage2(html); final WebElement input = driver.findElement(By.id("theInput")); assertEquals("input", input.getTagName()); input.click(); assertEquals(new URL(getDefaultUrl(), getExpectedAlerts()[0]).toString(), driver.getCurrentUrl()); }
From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchor2Test.java
License:Apache License
/** * @throws Exception if an error occurs//from w w w . j a v a 2 s . c om */ @Test @Alerts(DEFAULT = "page2.html", IE = "") public void clickNestedInputPasswordElement() throws Exception { final String html = "<html>\n" + "<body>\n" + " <a href='page2.html'>\n" + " <input type='password' id='theInput' />\n" + " </a>\n" + "</body></html>"; getMockWebConnection().setDefaultResponse(""); final WebDriver driver = loadPage2(html); final WebElement input = driver.findElement(By.id("theInput")); assertEquals("input", input.getTagName()); input.click(); assertEquals(new URL(getDefaultUrl(), getExpectedAlerts()[0]).toString(), driver.getCurrentUrl()); }
From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchor2Test.java
License:Apache License
/** * @throws Exception if an error occurs//w w w. j a va2 s . co m */ @Test public void clickNestedOptionElement() throws Exception { final String html = "<html>\n" + "<body>\n" + " <a href='page2.html'>\n" + " <select>\n" + " <option id='theOption'>test</option>\n" + " </select>\n" + " </a>\n" + "</body></html>"; getMockWebConnection().setDefaultResponse(""); final WebDriver driver = loadPage2(html); final WebElement option = driver.findElement(By.id("theOption")); assertEquals("option", option.getTagName()); option.click(); assertEquals(new URL(getDefaultUrl(), "page2.html").toString(), driver.getCurrentUrl()); }
From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchor2Test.java
License:Apache License
/** * @throws Exception if an error occurs/*from w ww . ja v a2s . c om*/ */ @Test @Alerts(DEFAULT = "page2.html", CHROME = "", IE = "") public void clickNestedRadioElement() throws Exception { final String html = "<html>\n" + "<body>\n" + " <a href='page2.html'>\n" + " <input type='radio' id='theRadio' name='myRadio' value='Milk'>\n" + " </a>\n" + "</body></html>"; getMockWebConnection().setDefaultResponse(""); final WebDriver driver = loadPage2(html); final WebElement radio = driver.findElement(By.id("theRadio")); assertEquals("input", radio.getTagName()); radio.click(); assertEquals(new URL(getDefaultUrl(), getExpectedAlerts()[0]).toString(), driver.getCurrentUrl()); }
From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchor2Test.java
License:Apache License
/** * @throws Exception if an error occurs// ww w. ja va2 s . c om */ @Test @Alerts("page2.html") public void clickNestedResetElement() throws Exception { final String html = "<html>\n" + "<body>\n" + " <a href='page2.html'>\n" + " <input type='reset' id='theInput' />\n" + " </a>\n" + "</body></html>"; getMockWebConnection().setDefaultResponse(""); final WebDriver driver = loadPage2(html); final WebElement input = driver.findElement(By.id("theInput")); assertEquals("input", input.getTagName()); input.click(); assertEquals(new URL(getDefaultUrl(), getExpectedAlerts()[0]).toString(), driver.getCurrentUrl()); }
From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchor2Test.java
License:Apache License
/** * @throws Exception if an error occurs/*from www . j a va2 s .c o m*/ */ @Test @Alerts("page2.html") public void clickNestedSubmitElement() throws Exception { final String html = "<html>\n" + "<body>\n" + " <a href='page2.html'>\n" + " <input type='submit' id='theInput' />\n" + " </a>\n" + "</body></html>"; getMockWebConnection().setDefaultResponse(""); final WebDriver driver = loadPage2(html); final WebElement input = driver.findElement(By.id("theInput")); assertEquals("input", input.getTagName()); input.click(); assertEquals(new URL(getDefaultUrl(), getExpectedAlerts()[0]).toString(), driver.getCurrentUrl()); }
From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchor2Test.java
License:Apache License
/** * @throws Exception if the test fails//from w w w. ja v a 2 s .co m */ @Test public void click() throws Exception { final String html = "<html>\n" + "<head><title>foo</title></head>\n" + "<body>\n" + "<a href='http://www.foo1.com' id='a1'>link to foo1</a>\n" + "<a href='" + URL_SECOND + "' id='a2'>link to foo2</a>\n" + "</body></html>"; final String secondContent = "<html><head><title>Second</title></head><body></body></html>"; final MockWebConnection webConnection = getMockWebConnection(); webConnection.setDefaultResponse(secondContent); final WebDriver driver = loadPage2(html); assertEquals(1, webConnection.getRequestCount()); // Test that the correct value is being passed back up to the server driver.findElement(By.id("a2")).click(); assertEquals(URL_SECOND.toExternalForm(), driver.getCurrentUrl()); assertSame("method", HttpMethod.GET, webConnection.getLastMethod()); assertTrue(webConnection.getLastParameters().isEmpty()); assertEquals(2, webConnection.getRequestCount()); }
From source file:com.gargoylesoftware.htmlunit.html.HtmlAnchorTest.java
License:Apache License
/** * @throws Exception if an error occurs/*from w ww . j a v a 2s. c o m*/ */ @Test public void clickNestedElement() throws Exception { final String html = "<html>\n" + "<body>\n" + " <a href='page2.html'>\n" + " <span id='theSpan'>My Link</span>\n" + " </a>\n" + "</body></html>"; getMockWebConnection().setDefaultResponse(""); final WebDriver driver = loadPage2(html); final WebElement span = driver.findElement(By.id("theSpan")); assertEquals("span", span.getTagName()); span.click(); assertEquals(URL_FIRST + "page2.html", driver.getCurrentUrl()); }