Skip to content

Commit

Permalink
feat(selenium): add ReadUrl and deprecate ReadCurrentUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianth committed May 30, 2018
1 parent 78e7052 commit 6b67603
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,32 +1,5 @@
package org.getopentest.selenium;

import org.getopentest.selenium.core.SeleniumTestAction;
import java.net.URL;

public class ReadCurrentUrl extends SeleniumTestAction {

@Override
public void run() {
super.run();

try {
String urlValue = driver.getCurrentUrl();
URL currentUrl = new URL(urlValue);

this.writeOutput("anchor", currentUrl.getRef());
this.writeOutput("authority", currentUrl.getAuthority());
this.writeOutput("defaultPort", currentUrl.getDefaultPort());
this.writeOutput("file", currentUrl.getFile());
this.writeOutput("host", currentUrl.getHost());
this.writeOutput("path", currentUrl.getPath());
int port = currentUrl.getPort();
this.writeOutput("port", port > 0 ? port : null);
this.writeOutput("protocol", currentUrl.getProtocol());
this.writeOutput("query", currentUrl.getQuery());
this.writeOutput("userInfo", currentUrl.getUserInfo());
this.writeOutput("url", urlValue);
} catch (Throwable ex) {
throw new RuntimeException("Failed reading the current URL", ex);
}
}
@Deprecated
public class ReadCurrentUrl extends ReadUrl {
}
32 changes: 32 additions & 0 deletions actor/selenium/src/main/java/org/getopentest/selenium/ReadUrl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.getopentest.selenium;

import org.getopentest.selenium.core.SeleniumTestAction;
import java.net.URL;

public class ReadUrl extends SeleniumTestAction {

@Override
public void run() {
super.run();

try {
String urlValue = driver.getCurrentUrl();
URL currentUrl = new URL(urlValue);

this.writeOutput("anchor", currentUrl.getRef());
this.writeOutput("authority", currentUrl.getAuthority());
this.writeOutput("defaultPort", currentUrl.getDefaultPort());
this.writeOutput("file", currentUrl.getFile());
this.writeOutput("host", currentUrl.getHost());
this.writeOutput("path", currentUrl.getPath());
int port = currentUrl.getPort();
this.writeOutput("port", port > 0 ? port : null);
this.writeOutput("protocol", currentUrl.getProtocol());
this.writeOutput("query", currentUrl.getQuery());
this.writeOutput("userInfo", currentUrl.getUserInfo());
this.writeOutput("url", urlValue);
} catch (Throwable ex) {
throw new RuntimeException("Failed reading the current URL", ex);
}
}
}

0 comments on commit 6b67603

Please sign in to comment.