From 6b67603e318c1ca4a701a0c1a7b382c0d8767aed Mon Sep 17 00:00:00 2001 From: Adrian Theodorescu Date: Tue, 29 May 2018 21:43:48 -0500 Subject: [PATCH] feat(selenium): add ReadUrl and deprecate ReadCurrentUrl --- .../getopentest/selenium/ReadCurrentUrl.java | 31 ++---------------- .../org/getopentest/selenium/ReadUrl.java | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+), 29 deletions(-) create mode 100644 actor/selenium/src/main/java/org/getopentest/selenium/ReadUrl.java diff --git a/actor/selenium/src/main/java/org/getopentest/selenium/ReadCurrentUrl.java b/actor/selenium/src/main/java/org/getopentest/selenium/ReadCurrentUrl.java index 0ffa009e..a4c1989a 100644 --- a/actor/selenium/src/main/java/org/getopentest/selenium/ReadCurrentUrl.java +++ b/actor/selenium/src/main/java/org/getopentest/selenium/ReadCurrentUrl.java @@ -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 { } diff --git a/actor/selenium/src/main/java/org/getopentest/selenium/ReadUrl.java b/actor/selenium/src/main/java/org/getopentest/selenium/ReadUrl.java new file mode 100644 index 00000000..c04e81c9 --- /dev/null +++ b/actor/selenium/src/main/java/org/getopentest/selenium/ReadUrl.java @@ -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); + } + } +}