1
1
package MyRunner ;
2
2
3
- import java .net .URL ;
4
-
5
3
import io .cucumber .testng .AbstractTestNGCucumberTests ;
6
4
import io .cucumber .testng .CucumberOptions ;
7
5
import io .cucumber .testng .TestNGCucumberRunner ;
6
+ import manager .Driver ;
7
+ import manager .DriverManager ;
8
8
import org .openqa .selenium .remote .CapabilityType ;
9
9
import org .openqa .selenium .remote .DesiredCapabilities ;
10
10
import org .openqa .selenium .remote .RemoteWebDriver ;
11
- import org .testng .annotations .AfterClass ;
12
- import org .testng .annotations .BeforeClass ;
13
- import org .testng .annotations .BeforeMethod ;
14
- import org .testng .annotations .DataProvider ;
15
- import org .testng .annotations .Parameters ;
11
+ import org .testng .annotations .*;
16
12
13
+ import java .net .URL ;
17
14
18
15
@ CucumberOptions (
19
- features = "src/main/java/Features/todo.feature" ,
20
- glue = {"stepDefinitions" },
21
- plugin = "json:target/cucumber-reports/CucumberTestReport.json" )
16
+ features = "src/main/java/Features/todo.feature" ,
17
+ glue = {"stepDefinitions" },
18
+ plugin = "json:target/cucumber-reports/CucumberTestReport.json" )
19
+
20
+ public final class TestRunner extends AbstractTestNGCucumberTests {
21
+
22
+ private TestNGCucumberRunner testNGCucumberRunner ;
23
+
24
+ @ BeforeClass (alwaysRun = true )
25
+ public void setUpCucumber () {
26
+ testNGCucumberRunner = new TestNGCucumberRunner (this .getClass ());
27
+ }
28
+
29
+ @ BeforeMethod (alwaysRun = true )
30
+ @ Parameters ({ "browser" , "version" , "platform" })
31
+ public void setUpClass (String browser , String version , String platform ) throws Exception {
32
+
33
+ RemoteWebDriver remoteWebdriver = null ;
34
+
35
+ String username = System .getenv ("LT_USERNAME" ) == null ? "YOUR LT_USERNAME" : System .getenv ("LT_USERNAME" );
36
+ String accesskey = System .getenv ("LT_ACCESS_KEY" ) == null ? "YOUR LT_ACCESS_KEY" : System .getenv ("LT_ACCESS_KEY" );
22
37
23
- public class TestRunner extends AbstractTestNGCucumberTests {
24
-
25
- private TestNGCucumberRunner testNGCucumberRunner ;
26
-
27
- public static RemoteWebDriver connection ;
28
-
29
- @ BeforeClass (alwaysRun = true )
30
- public void setUpCucumber () {
31
- testNGCucumberRunner = new TestNGCucumberRunner (this .getClass ());
32
- }
33
-
34
- @ BeforeMethod (alwaysRun = true )
35
- @ Parameters ({ "browser" , "version" , "platform" })
36
- public void setUpClass (String browser , String version , String platform ) throws Exception {
38
+ DesiredCapabilities capability = new DesiredCapabilities ();
39
+ capability .setCapability (CapabilityType .BROWSER_NAME , browser );
40
+ capability .setCapability (CapabilityType .VERSION , version );
41
+ capability .setCapability (CapabilityType .PLATFORM , platform );
37
42
38
- String username = System .getenv ("LT_USERNAME" ) == null ? "YOUR LT_USERNAME" : System .getenv ("LT_USERNAME" );
39
- String accesskey = System .getenv ("LT_ACCESS_KEY" ) == null ? "YOUR LT_ACCESS_KEY" : System .getenv ("LT_ACCESS_KEY" );
43
+ capability .setCapability ("build" , "Cucumber Sample Build" );
40
44
41
- DesiredCapabilities capability = new DesiredCapabilities ();
42
- capability .setCapability (CapabilityType .BROWSER_NAME , browser );
43
- capability .setCapability (CapabilityType .VERSION ,version );
44
- capability .setCapability (CapabilityType .PLATFORM , platform );
45
-
46
- capability .setCapability ("build" , "Cucumber Sample Build" );
47
-
48
- capability .setCapability ("network" , true );
49
- capability .setCapability ("video" , true );
50
- capability .setCapability ("console" , true );
51
- capability .setCapability ("visual" , true );
45
+ capability .setCapability ("network" , true );
46
+ capability .setCapability ("video" , true );
47
+ capability .setCapability ("console" , true );
48
+ capability .setCapability ("visual" , true );
52
49
53
- String gridURL = "https://" + username + ":" + accesskey + "@hub.lambdatest.com/wd/hub" ;
54
- System .out .println (gridURL );
55
- connection = new RemoteWebDriver (new URL (gridURL ), capability );
56
- System .out .println (capability );
57
- System .out .println (connection .getSessionId ());
58
- }
50
+ String gridURL = "https://" + username + ":" + accesskey + "@hub.lambdatest.com/wd/hub" ;
51
+ System .out .println (gridURL );
52
+ remoteWebdriver = new RemoteWebDriver (new URL (gridURL ), capability );
53
+ System .out .println (capability );
54
+ Driver .initDriver (remoteWebdriver );
55
+ System .out .println (DriverManager .getDriver ().getSessionId ());
56
+ }
59
57
58
+ @ DataProvider
59
+ public Object [][] features () {
60
+ return testNGCucumberRunner .provideScenarios ();
61
+ }
60
62
61
- @ DataProvider
62
- public Object [][] features () {
63
- return testNGCucumberRunner .provideScenarios ();
64
- }
65
-
66
- @ AfterClass (alwaysRun = true )
67
- public void tearDownClass () {
68
- testNGCucumberRunner .finish ();
69
- }
63
+ @ AfterClass (alwaysRun = true )
64
+ public void tearDownClass () {
65
+ testNGCucumberRunner .finish ();
66
+ }
70
67
}
0 commit comments