1
+ package playwrightsessions ;
2
+
3
+ import java .nio .file .Paths ;
4
+
5
+ import com .microsoft .playwright .*;
6
+
7
+
8
+ public class Example {
9
+ public static void main (String [] args ) {
10
+ try (Playwright playwright = Playwright .create ()) {
11
+ Browser browser = playwright .firefox ().launch (new BrowserType .LaunchOptions ()
12
+ .setHeadless (false ));
13
+ BrowserContext context = browser .newContext ();
14
+
15
+ context .tracing ().start (new Tracing .StartOptions ()
16
+ .setScreenshots (true )
17
+ .setSnapshots (true ));
18
+
19
+ // Open new page
20
+ Page page = context .newPage ();
21
+
22
+ // Go to https://academy.naveenautomationlabs.com/
23
+ page .navigate ("https://academy.naveenautomationlabs.com/" );
24
+
25
+ // Click text=Login
26
+ page .click ("text=Login" );
27
+
28
+ page .pause ();
29
+ // Click button:has-text("Sign Up")
30
+ page .click ("button:has-text(\" Sign Up\" )" );
31
+
32
+ // Click [placeholder="Name"]
33
+ page .click ("[placeholder=\" Name\" ]" );
34
+
35
+ // Fill [placeholder="Name"]
36
+ page .fill ("[placeholder=\" Name\" ]" , "testingautomatiomn" );
37
+
38
+ // Fill [placeholder="Email"]
39
+ page .
fill (
"[placeholder=\" Email\" ]" ,
"[email protected] " );
40
+
41
+
42
+ // Fill [placeholder="Create Password"]
43
+ page .fill ("[placeholder=\" Create Password\" ]" , "test123" );
44
+
45
+ // Click text=+971
46
+ page .click ("text=+971" );
47
+
48
+ // Click :nth-match(:text("India (भारत)"), 2)
49
+ page .click (":nth-match(:text(\" India (भारत)\" ), 2)" );
50
+
51
+ // Click [placeholder="Mobile"]
52
+ page .click ("[placeholder=\" Mobile\" ]" );
53
+
54
+ // Fill [placeholder="Mobile"]
55
+ page .fill ("[placeholder=\" Mobile\" ]" , "9898989898" );
56
+
57
+ // Click text=By signing up, I agree to the Terms of Use and Privacy Policy. >> i
58
+ page .click ("text=By signing up, I agree to the Terms of Use and Privacy Policy. >> i" );
59
+
60
+ // Click #loginFormHtml div [aria-label="Close"]
61
+ page .click ("#loginFormHtml div [aria-label=\" Close\" ]" );
62
+
63
+ context .tracing ().stop (new Tracing .StopOptions ()
64
+ .setPath (Paths .get ("trace.zip" )));
65
+
66
+ }
67
+ }
68
+ }
0 commit comments