Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/main/java/testUI/IOSUtils/IOSCommands.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package testUI.IOSUtils;

import testUI.Utils.TestUIException;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
Expand Down Expand Up @@ -38,7 +36,7 @@ private Map<String, Map<String, String>> getSimulatorNames() {
line.split(" \\(")[0].split(" ")[1],
line.split("\\(")[1].split("\\)")[0]);
} else if (Devices && line.contains("iOS")) {
if (versions.size() != 0 && devices.size() != 0) {
if (!versions.isEmpty() && !devices.isEmpty()) {
iOS.put(versions.get(versions.size() - 1), devices);
devices = new HashMap<>();
}
Expand All @@ -49,10 +47,12 @@ private Map<String, Map<String, String>> getSimulatorNames() {
if (line.contains("== Devices ==")) {
Devices = true;
} else if (line.contains("== Device Pairs ==")) {
iOS.put(versions.get(versions.size() - 1), devices);
if (!iOS.isEmpty() && !devices.isEmpty())
iOS.put(versions.get(versions.size() - 1), devices);
Devices = false;
}
}
putLog("Found simulator devices: " + iOS);
return iOS;
}

Expand Down
13 changes: 1 addition & 12 deletions src/main/java/testUI/TestUIServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServiceBuilder;
import io.appium.java_client.service.local.flags.AndroidServerFlag;
import io.appium.java_client.service.local.flags.GeneralServerFlag;
import org.openqa.selenium.remote.DesiredCapabilities;
import testUI.AndroidUtils.ADBUtils;
Expand All @@ -29,7 +28,6 @@ public class TestUIServer extends UIUtils {

protected static void startServer(
String port,
String Bootstrap,
TestUIConfiguration configuration) {
AppiumServiceBuilder builder;
DesiredCapabilities cap;
Expand All @@ -43,7 +41,6 @@ protected static void startServer(
builder.withCapabilities(cap);
builder.withArgument(GeneralServerFlag.SESSION_OVERRIDE);
builder.withArgument(GeneralServerFlag.LOG_LEVEL, "info");
builder.withArgument(AndroidServerFlag.BOOTSTRAP_PORT_NUMBER, Bootstrap);
builder.withArgument(GeneralServerFlag.BASEPATH, configuration.getBaseAppiumPath());
//Start the server with the builder
TestUIServer.serviceRunning.set(false);
Expand Down Expand Up @@ -193,27 +190,21 @@ public static synchronized void startServerAndDevice(TestUIConfiguration configu
int emulators = configuration.isUseEmulators() ? adbUtils.getEmulatorName().size() : 0;
int totalDevices;
int ports;
int bootstrap;
int realDevices;
if (configuration.isiOSTesting()) {
ports = configuration.getBaseAppiumPort() + getUsePort().size() * 100 + 5;
bootstrap = configuration.getBaseAppiumBootstrapPort() +
getUseBootstrapPort().size() * 100;
totalDevices = 10;
realDevices = 0;

} else {
ports = configuration.getBaseAppiumPort() + getUsePort().size() * 100;
bootstrap = configuration.getBaseAppiumBootstrapPort() +
getUseBootstrapPort().size() * 100;
totalDevices = emulators + connectedDevices - startedEmulators;
realDevices = totalDevices - emulators;
}
String port = String.valueOf(ports);
String Bootstrap = String.valueOf(bootstrap);
for (int device = getUsePort().size(); device < totalDevices; device++) {
if (configuration.getAppiumUrl().isEmpty()) {
startServer(port, Bootstrap, configuration);
startServer(port, configuration);
attachShutDownHook(getAppiumServices(), getDrivers());
}
if (serviceRunning.get() || (!configuration.getAppiumUrl().isEmpty() &&
Expand All @@ -222,11 +213,9 @@ public static synchronized void startServerAndDevice(TestUIConfiguration configu
break;
}
port = String.valueOf(Integer.parseInt(port) + 100);
Bootstrap = String.valueOf(Integer.parseInt(Bootstrap) + 100);
}
if (configuration.getAppiumUrl().isEmpty()) {
setUsePort(port);
setUseBootstrapPort(Bootstrap);
putAllureParameter("Using Appium port", getUsePort()
.get(getUsePort().size() - 1));
} else {
Expand Down
24 changes: 13 additions & 11 deletions src/test/java/TestRunners/TestBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
import pages.GoogleLandingPage;
import testUI.Configuration;

import java.util.ArrayList;

import static testUI.TestUIDriver.*;
import static testUI.TestUIServer.stop;
import static testUI.UIOpen.open;
import static testUI.UIUtils.*;
import static testUI.Utils.AppiumHelps.sleep;
import static testUI.Utils.By.*;
import static testUI.Utils.Performance.getListOfCommandsTime;
import static testUI.Utils.Performance.logAverageTime;
Expand All @@ -36,7 +37,7 @@ public void testDesktopBrowser() {
executeJs("arguments[0].value='TestUI';", googleLandingPage.getGoogleSearchInput()
.getSelenideElement().getWrappedElement());
googleLandingPage.getGoogleSearch()
.then().saveScreenshot("~/target/screen.png");
.then().saveScreenshot("~/screen.png");
logAverageTime();
System.out.println(getListOfCommandsTime());

Expand All @@ -47,14 +48,13 @@ public void testDesktopBrowser() {
@Test
public void setDriverTest() {
ChromeOptions options = new ChromeOptions();
Configuration.softAsserts = false;
Configuration.softAsserts = true;
options.addArguments(
"--user-agent=Agent", "--ignore-certificate-errors", "--headless", "--remote-allow-origins=*");
Configuration.chromeOptions = options;
selenideBrowserCapabilities.setBrowserName("chrome");
open("https://www.whatismybrowser.com/detect/what-is-my-user-agent/");
E(byCssSelector("#detected_value a")).waitFor(10).untilHasText("Agent");
sleep(1000);
stop();
}

Expand All @@ -67,17 +67,16 @@ public void testDesktopBrowserStatusCode() {
Configuration.browser = "chrome";
Configuration.headless = true;
open("https://www.google.com")
.getNetworkCalls().logAllCalls().filterByExactUrl("https://www.google.com/")
.logFilteredCalls()
.getNetworkCalls().filterByExactUrl("https://www.google.com/")
.and()
.filterByUrl("https://www.google.com/").assertFilteredCallExists()
.logFilteredCalls().assertStatusCode(200)
.assertStatusCode(200)
.assertResponseHeader("Content-Type", "text/html; charset=UTF-8");

stop();
open("https://www.google.com")
.getLastNetworkCalls(100).logAllCalls()
.filterByUrl("https://www.google.com/").logFilteredCalls()
.getLastNetworkCalls(100)
.filterByUrl("https://www.google.com/")
.assertFilteredCallExists();
stop();
}
Expand All @@ -88,6 +87,7 @@ public void testDesktopCustomDriverBrowser() {
Configuration.automationType = DESKTOP_PLATFORM;
Configuration.browser = "chrome";
Configuration.headless = true;
Configuration.softAsserts = true;
open("https://www.google.com");
stop();
String userAgent = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)";
Expand All @@ -112,9 +112,11 @@ public void testAndroidBrowserOneLine() {
Configuration.softAsserts = true;
Configuration.browser = "chrome";
Configuration.headless = true;
Configuration.testUIErrors = new ArrayList<>();
Configuration.testUILogLevel = LogLevel.DEBUG;
open("https://loadero.com/login")
.given("I set element").setElement(byCssSelector("#username"))
open("https://loadero.com/login");
getSelenideDriver().switchTo().frame(1); // It uses iFrame now
E(byCssSelector("#username"))
.and("I check if visible").waitFor(5).untilIsVisible()
.and("I send keys").setValueJs("\\uD83D\\uDE00")
.given("I set element").setElement(byCssSelector("#password"))
Expand Down
16 changes: 0 additions & 16 deletions src/test/java/TestRunners/TestCucumber.java

This file was deleted.

16 changes: 0 additions & 16 deletions src/test/java/TestRunners/TestCucumber2.java

This file was deleted.

7 changes: 2 additions & 5 deletions src/test/java/TestRunners/TestIOS.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@

import io.qameta.allure.junit4.DisplayName;
import org.junit.Test;
import pages.FacebookLandingPage;
import testUI.Configuration;

import static testUI.TestUIDriver.getIOSTestUIDriver;
import static testUI.UIOpen.open;

public class TestIOS {
private FacebookLandingPage facebookLandingPage = new FacebookLandingPage();

@Test
@DisplayName("IOS browser test case")
public void testIOSBrowser() {
Configuration.automationType = Configuration.IOS_PLATFORM;
Configuration.serverLogLevel = "all";
Configuration.serverLogLevel = "debug";
Configuration.useNewWDA = false;
open("https://www.facebook.com");
System.out.println(getIOSTestUIDriver().getBatteryInfo().getState());
}
}
52 changes: 0 additions & 52 deletions src/test/resources/features/simple.feature

This file was deleted.

6 changes: 0 additions & 6 deletions src/test/resources/features/simple2.feature

This file was deleted.