diff --git a/src/main/java/testUI/IOSUtils/IOSCommands.java b/src/main/java/testUI/IOSUtils/IOSCommands.java index 2925a3f..2a50571 100644 --- a/src/main/java/testUI/IOSUtils/IOSCommands.java +++ b/src/main/java/testUI/IOSUtils/IOSCommands.java @@ -1,7 +1,5 @@ package testUI.IOSUtils; -import testUI.Utils.TestUIException; - import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; @@ -38,7 +36,7 @@ private Map> 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<>(); } @@ -49,10 +47,12 @@ private Map> 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; } diff --git a/src/main/java/testUI/TestUIServer.java b/src/main/java/testUI/TestUIServer.java index 9e87f37..32cc5bb 100644 --- a/src/main/java/testUI/TestUIServer.java +++ b/src/main/java/testUI/TestUIServer.java @@ -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; @@ -29,7 +28,6 @@ public class TestUIServer extends UIUtils { protected static void startServer( String port, - String Bootstrap, TestUIConfiguration configuration) { AppiumServiceBuilder builder; DesiredCapabilities cap; @@ -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); @@ -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() && @@ -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 { diff --git a/src/test/java/TestRunners/TestBrowser.java b/src/test/java/TestRunners/TestBrowser.java index df709de..fae349d 100644 --- a/src/test/java/TestRunners/TestBrowser.java +++ b/src/test/java/TestRunners/TestBrowser.java @@ -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; @@ -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()); @@ -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(); } @@ -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(); } @@ -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)"; @@ -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")) diff --git a/src/test/java/TestRunners/TestCucumber.java b/src/test/java/TestRunners/TestCucumber.java deleted file mode 100644 index 8438bd1..0000000 --- a/src/test/java/TestRunners/TestCucumber.java +++ /dev/null @@ -1,16 +0,0 @@ -package TestRunners; - -import cucumber.api.CucumberOptions; -import cucumber.api.junit.Cucumber; -import org.junit.runner.RunWith; - -@RunWith(Cucumber.class) -@CucumberOptions( - glue = "stepDefinitions", - features = {"src/test/resources/features/"}, - plugin = {"pretty","io.qameta.allure.cucumber4jvm.AllureCucumber4Jvm", - "json:target/cucumber-reports/file.json"}, - tags = {"@testBrowser"} -) -public class TestCucumber { -} diff --git a/src/test/java/TestRunners/TestCucumber2.java b/src/test/java/TestRunners/TestCucumber2.java deleted file mode 100644 index f803943..0000000 --- a/src/test/java/TestRunners/TestCucumber2.java +++ /dev/null @@ -1,16 +0,0 @@ -package TestRunners; - -import cucumber.api.CucumberOptions; -import cucumber.api.junit.Cucumber; -import org.junit.runner.RunWith; - -@RunWith(Cucumber.class) -@CucumberOptions( - glue = "stepDefinitions", - features = {"src/test/resources/features/"}, - plugin = {"pretty","io.qameta.allure.cucumber4jvm.AllureCucumber4Jvm", - "json:target/cucumber-reports/file.json"}, - tags = {"@testBrowser"} -) -public class TestCucumber2 { -} diff --git a/src/test/java/TestRunners/TestIOS.java b/src/test/java/TestRunners/TestIOS.java index bc75cae..39b85b8 100644 --- a/src/test/java/TestRunners/TestIOS.java +++ b/src/test/java/TestRunners/TestIOS.java @@ -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()); } } diff --git a/src/test/resources/features/simple.feature b/src/test/resources/features/simple.feature deleted file mode 100644 index cc90989..0000000 --- a/src/test/resources/features/simple.feature +++ /dev/null @@ -1,52 +0,0 @@ -Feature: Simple Feature - - @testApp - Scenario: Android app scenario - When I click on catering - Then I click on near me - Then I click on suggested - Then I click on map - - @testApp - Scenario: Android app scenario - When I click on catering - Then I click on near me - Then I click on suggested - Then I click on map - - @testBrowser - Scenario: Android chrome browser scenario - When I search for Appium in Google - - @testLaptopBrowser - Scenario: Laptop browser scenario - When I search for Appium in Google - - @testLaptopAndMobile - Scenario: Laptop and Mobile Browser scenario - Given I am using laptop browser - Then I search for Appium in Google - Given I am using mobile browser - Then I search for TestUI in Google - And I take screenshot in all devices - - @testLaptopAndMobileFail - Scenario: Laptop and Mobile Browser scenario - Given I am using laptop browser - Then I search for Appium in Google and fail assertion - Given I am using mobile browser - Then I search for TestUI in Google - - @IOS - Scenario: iOS app scenario - Given I in IOS landing app - Then I click on the second iOS app button - And I click on the first iOS app button - - @IOSBrowser - Scenario: iOS Safari Browser scenario - When I enter email email@test.com and password password in facebook landing page - - @IOSBrowserFail - Scenario: iOS Safari Browser scenario - When I enter email email@test.com and password password in facebook landing page \ No newline at end of file diff --git a/src/test/resources/features/simple2.feature b/src/test/resources/features/simple2.feature deleted file mode 100644 index 9f2e732..0000000 --- a/src/test/resources/features/simple2.feature +++ /dev/null @@ -1,6 +0,0 @@ -Feature: Simple Feature - - @parallel - @testBrowser - Scenario: Simple scenario - When I search for Appium in Google \ No newline at end of file