Skip to content

Commit 5975d47

Browse files
committed
Changing the tests for getCurrentUrl to conform to the standard
1 parent 4d115c6 commit 5975d47

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

java/client/test/org/openqa/selenium/FrameSwitchingTest.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
import static org.openqa.selenium.support.ui.ExpectedConditions.titleIs;
3232
import static org.openqa.selenium.testing.Ignore.Driver.ALL;
3333
import static org.openqa.selenium.testing.Ignore.Driver.CHROME;
34+
import static org.openqa.selenium.testing.Ignore.Driver.FIREFOX;
35+
import static org.openqa.selenium.testing.Ignore.Driver.HTMLUNIT;
3436
import static org.openqa.selenium.testing.Ignore.Driver.IE;
3537
import static org.openqa.selenium.testing.Ignore.Driver.MARIONETTE;
3638
import static org.openqa.selenium.testing.Ignore.Driver.PHANTOMJS;
@@ -412,23 +414,24 @@ public void testShouldBeAbleToFindElementsInIframesByXPath() {
412414
assertNotNull(element);
413415
}
414416

415-
@Ignore({MARIONETTE})
417+
@Ignore({CHROME, FIREFOX, HTMLUNIT, IE, PHANTOMJS, SAFARI})
416418
@Test
417-
public void testGetCurrentUrl() {
419+
public void testGetCurrentUrlReturnsTopLevelBrowsingContextUrl() {
418420
driver.get(pages.framesetPage);
421+
assertThat(driver.getCurrentUrl(), equalTo(pages.framesetPage));
419422

420423
driver.switchTo().frame("second");
424+
assertThat(driver.getCurrentUrl(), equalTo(pages.framesetPage));
425+
}
421426

422-
String url = appServer.whereIs("page/2");
423-
assertThat(driver.getCurrentUrl(), equalTo(url + "?title=Fish"));
424-
425-
url = appServer.whereIs("iframes.html");
427+
@Ignore({CHROME, FIREFOX, HTMLUNIT, IE, PHANTOMJS, SAFARI})
428+
@Test
429+
public void testGetCurrentUrlReturnsTopLevelBrowsingContextUrlForIframes() {
426430
driver.get(pages.iframePage);
427-
assertThat(driver.getCurrentUrl(), equalTo(url));
431+
assertThat(driver.getCurrentUrl(), equalTo(pages.iframePage));
428432

429-
url = appServer.whereIs("formPage.html");
430-
driver.switchTo().frame("iframe1");
431-
assertThat(driver.getCurrentUrl(), equalTo(url));
433+
driver.switchTo().frame("second");
434+
assertThat(driver.getCurrentUrl(), equalTo(pages.iframePage));
432435
}
433436

434437
@Ignore(value = {PHANTOMJS})
@@ -544,7 +547,6 @@ public void testJavaScriptShouldExecuteInTheContextOfTheCurrentFrame() {
544547
assertTrue((Boolean) executor.executeScript("return window != window.top"));
545548
}
546549

547-
@Ignore(MARIONETTE)
548550
@Test
549551
public void testShouldNotSwitchMagicallyToTheTopWindow() {
550552
String baseUrl = appServer.whereIs("frame_switching_tests/");
@@ -560,7 +562,7 @@ public void testShouldNotSwitchMagicallyToTheTopWindow() {
560562
input.sendKeys("rand" + new Random().nextInt());
561563
submit.click();
562564
} finally {
563-
String url = driver.getCurrentUrl();
565+
String url = (String) ((JavascriptExecutor) driver).executeScript("return window.location.href");
564566
// IE6 and Chrome add "?"-symbol to the end of the URL
565567
if (url.endsWith("?")) {
566568
url = url.substring(0, url.length()-1);

0 commit comments

Comments
 (0)