Skip to content

Commit 2aa89aa

Browse files
Merge pull request #96 from testdevlab/browser_test
add test for chrome browser
2 parents 5d07bec + 6485a7c commit 2aa89aa

3 files changed

Lines changed: 47 additions & 29 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: TestUI CI integration tests workflow
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
workflow_dispatch:
12+
13+
jobs:
14+
integration_test:
15+
runs-on: ubuntu-latest
16+
continue-on-error: true
17+
18+
steps:
19+
- uses: actions/checkout@v3
20+
- name: Set up JDK 11
21+
uses: actions/setup-java@v2
22+
with:
23+
java-version: 11
24+
distribution: "zulu"
25+
- name: Remove Chrome
26+
run: sudo apt purge google-chrome-stable
27+
- name: Remove default Chromium
28+
run: sudo apt purge chromium-browser
29+
- name: Install a new Chromium
30+
run: sudo apt install -y chromium-browser
31+
- name: Integration browser test with Maven
32+
run: mvn -Dtest=TestBrowser test

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<artifactId>maven-surefire-plugin</artifactId>
6767
<version>3.0.0-M3</version>
6868
<configuration>
69-
<testFailureIgnore>true</testFailureIgnore>
69+
<testFailureIgnore>false</testFailureIgnore>
7070
<argLine>
7171
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
7272
</argLine>
@@ -170,7 +170,7 @@
170170
<groupId>com.codeborne</groupId>
171171
<artifactId>selenide</artifactId>
172172

173-
<version>6.10.1</version>
173+
<version>6.12.2</version>
174174
</dependency>
175175
<dependency>
176176
<groupId>org.slf4j</groupId>

src/test/java/TestRunners/TestBrowser.java

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.junit.Test;
66
import org.openqa.selenium.chrome.ChromeDriver;
77
import org.openqa.selenium.chrome.ChromeOptions;
8+
import org.openqa.selenium.remote.DesiredCapabilities;
89
import pages.GoogleLandingPage;
910
import testUI.Configuration;
1011

@@ -29,54 +30,33 @@ public void testDesktopBrowser() {
2930
Configuration.testUILogLevel = LogLevel.DEBUG;
3031
Configuration.softAsserts = true;
3132
Configuration.browser = "chrome";
33+
Configuration.headless = true;
3234
open("https://www.google.com");
3335
UIAssert("the url is not correct",
3436
getSelenideDriver().getCurrentUrl().equals("https://www.google.com/"));
3537
executeJs("arguments[0].value='TestUI';", googleLandingPage.getGoogleSearchInput()
3638
.getSelenideElement().getWrappedElement());
3739
googleLandingPage.getGoogleSearch()
38-
.then().saveScreenshot("~/Documents" +
39-
"/screen" +
40-
".png");
40+
.then().saveScreenshot("~/target/screen.png");
4141
logAverageTime();
4242
System.out.println(getListOfCommandsTime());
4343

4444
raiseSoftAsserts();
45+
stop();
4546
}
4647

4748
@Test
4849
public void setDriverTest() {
4950
ChromeOptions options = new ChromeOptions();
5051
Configuration.softAsserts = false;
51-
options.addArguments("--user-agent=Agent", "--ignore-certificate-errors");
52+
options.addArguments(
53+
"--user-agent=Agent", "--ignore-certificate-errors", "--headless", "--remote-allow-origins=*");
5254
Configuration.chromeOptions = options;
5355
selenideBrowserCapabilities.setBrowserName("chrome");
5456
open("https://www.whatsmyua.info/");
5557
E(byCssSelector("textarea")).waitFor(10).untilHasText("Agent");
5658
sleep(1000);
57-
}
58-
59-
@Test
60-
@DisplayName("Laptop browser test case")
61-
public void testDesktopBrowserSafari() {
62-
Configuration.automationType = DESKTOP_PLATFORM;
63-
Configuration.browser = "safari";
64-
Configuration.serverLogLevel = "all";
65-
Configuration.softAsserts = true;
66-
open("https://www.google.com");
67-
System.out.println(getTestUIDriver().getCurrentUrl());
68-
executeJs("arguments[0].value='TestUI';", googleLandingPage.getGoogleSearchInput()
69-
.getSelenideElement().getWrappedElement());
70-
googleLandingPage.getGoogleSearch().given()
71-
.then().click().saveScreenshot("/Users/alvarolasernalopez/Documents/screen" +
72-
".png");
7359
stop();
74-
open("https://www.google.com");
75-
googleLandingPage.getGoogleSearch().given().waitFor(10).untilIsVisible()
76-
.then().click().saveScreenshot("/Users/alvarolasernalopez/Documents/screen" +
77-
".png");
78-
79-
raiseSoftAsserts();
8060
}
8161

8262

@@ -86,6 +66,7 @@ public void testDesktopBrowserStatusCode() {
8666
Configuration.automationType = DESKTOP_PLATFORM;
8767
Configuration.logNetworkCalls = true;
8868
Configuration.browser = "chrome";
69+
Configuration.headless = true;
8970
open("https://www.google.com")
9071
.getNetworkCalls().logAllCalls().filterByExactUrl("https://www.google.com/")
9172
.logFilteredCalls()
@@ -107,11 +88,14 @@ public void testDesktopBrowserStatusCode() {
10788
public void testDesktopCustomDriverBrowser() {
10889
Configuration.automationType = DESKTOP_PLATFORM;
10990
Configuration.browser = "chrome";
91+
Configuration.headless = true;
11092
open("https://www.google.com");
11193
stop();
112-
ChromeOptions options = new ChromeOptions();
11394
String userAgent = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)";
95+
ChromeOptions options = new ChromeOptions();
96+
options.addArguments("--remote-allow-origins=*");
11497
options.addArguments("--user-agent=" + userAgent);
98+
options.addArguments("--headless");
11599
ChromeDriver chromeDriver = new ChromeDriver(options);
116100
setDriver(chromeDriver);
117101
open("https://www.whatsmyua.info/");
@@ -128,6 +112,7 @@ public void testAndroidBrowserOneLine() {
128112
Configuration.useAllure = false;
129113
Configuration.softAsserts = true;
130114
Configuration.browser = "chrome";
115+
Configuration.headless = true;
131116
Configuration.testUILogLevel = LogLevel.DEBUG;
132117
open("https://loadero.com/login")
133118
.given("I set element").setElement(byCssSelector("#username"))
@@ -139,5 +124,6 @@ public void testAndroidBrowserOneLine() {
139124
.then("I find the submit").setElement(byCssSelector("[type=\"submit\"]"))
140125
.and("I click on it").click();
141126
raiseSoftAsserts();
127+
stop();
142128
}
143129
}

0 commit comments

Comments
 (0)