Skip to content

Commit

Permalink
SimonStewart: Applying patch from Amitabh Saikia that fixes the behav…
Browse files Browse the repository at this point in the history
…iour of getCurrentUrl to report the URL of the frame we are switched to. This is issue SeleniumHQ#67

r5833
  • Loading branch information
shs96c committed Nov 13, 2008
1 parent f6264f5 commit f240dfb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
1 change: 1 addition & 0 deletions CREDITS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ Marc Guillemot
Alexis Vuillemin
Noel Gordon
David Wang
Amitabh Saikia

14 changes: 14 additions & 0 deletions common/test/java/org/openqa/selenium/FrameSwitchingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,18 @@ public void testShouldBeAbleToFindElementsInIframesByXPath() {

assertNotNull(element);
}

@Ignore("safari")
public void testGetCurrentUrl() {
driver.get(framesetPage);

driver.switchTo().frame("second");
assertThat(driver.getCurrentUrl(), equalTo("http://localhost:3000/page/2?title=Fish"));

driver.get(iframePage);
assertThat(driver.getCurrentUrl(), equalTo("http://localhost:3000/iframes.html"));

driver.switchTo().frame("iframe1");
assertThat(driver.getCurrentUrl(), equalTo("http://localhost:3000/formPage.html"));
}
}
18 changes: 9 additions & 9 deletions firefox/src/extension/components/context.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
function Context(windowId, frameId) {
this.windowId = (windowId !== undefined ? windowId - 0 : 1) || 0;
this.windowId = (windowId !== undefined ? windowId - 0 : 1) || 0;

if (frameId) {
if (frameId.match(/^\d+$/g)) {
this.frameId = frameId - 0;
} else {
this.frameId = frameId;
}
}
if (frameId) {
if (frameId.match(/^\d+$/g)) {
this.frameId = frameId - 0;
} else {
this.frameId = frameId;
}
}
}

Context.fromString = function(text) {
Expand All @@ -17,4 +17,4 @@ Context.fromString = function(text) {

Context.prototype.toString = function() {
return this.windowId + " " + (this.frameId !== undefined ? this.frameId : "");
}
}
6 changes: 5 additions & 1 deletion firefox/src/extension/components/firefoxDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ FirefoxDriver.prototype.executeScript = function(respond, script) {

FirefoxDriver.prototype.getCurrentUrl = function(respond) {
respond.context = this.context;
respond.response = "" + Utils.getBrowser(this.context).contentWindow.location;
var url = Utils.getDocument(this.context).location;
if (!url) {
url = Utils.getBrowser(this.context).contentWindow.location;
}
respond.response = "" + url;
respond.send();
}

Expand Down

0 comments on commit f240dfb

Please sign in to comment.