55import org .junit .Test ;
66import org .openqa .selenium .chrome .ChromeDriver ;
77import org .openqa .selenium .chrome .ChromeOptions ;
8+ import org .openqa .selenium .remote .DesiredCapabilities ;
89import pages .GoogleLandingPage ;
910import 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