Skip to content

Commit

Permalink
Merge pull request #27 from CoSMoSoftware/Anthony
Browse files Browse the repository at this point in the history
Anthony
  • Loading branch information
namvuCosmo authored Jul 3, 2019
2 parents 43e593b + ab86bc4 commit cfd7ad4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,6 @@

</properties>

<version>0.1.30</version>
<version>0.1.31</version>

</project>
28 changes: 28 additions & 0 deletions src/main/java/io/cosmosoftware/kite/util/WebDriverUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,20 @@
import io.appium.java_client.touch.WaitOptions;
import io.appium.java_client.touch.offset.PointOption;
import io.cosmosoftware.kite.exception.KiteInteractionException;
import io.cosmosoftware.kite.exception.KiteTestException;
import io.cosmosoftware.kite.report.KiteLogger;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.time.Duration;
import java.util.List;
import java.util.concurrent.TimeUnit;

import io.cosmosoftware.kite.report.Status;
import org.openqa.selenium.By;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.Dimension;
Expand Down Expand Up @@ -807,4 +817,22 @@ public static void waitForExpectedNumberOfElements(WebDriver webDriver, By selec
"Timeout waiting for " + expectedNumber + " elements: " + selector.toString());
}

/**
* Gets the my public ip.
*
* @return the my public ip
*
* @throws IOException Signals that an I/O exception has occurred.
*/
public static String getPublicIp(WebDriver webDriver) throws KiteTestException {
String publicIpURL = "http://bot.whatismyipaddress.com";
webDriver.get(publicIpURL);
String pageSource = webDriver.getPageSource();
try {
return pageSource.split("<body>")[1].split("</body>")[0];
} catch (Exception e) {
throw new KiteTestException("Could not get public IP for webdriver session: "
+ ((RemoteWebDriver)webDriver).getSessionId(), Status.BROKEN);
}
}
}

0 comments on commit cfd7ad4

Please sign in to comment.