1
2 Test scenario :
3
4 Creating a class
5 Create separate methods for all the functionality
6 Calling these methods in the same class
7 For reusable purpose we use to create separated methods
8 and we call them
9
10 Class A: testing
11 Opening
12 Title
13 url
14 searching
15 screenshot
16 close
17
18
19 Class B:testing1
20
21 Testing a1=new Testing();
22 [Link]();
23 [Link]();
24 [Link]();
25
26
27 Test Scenario
28 Opening amazon page
29 Max the window
30 Get the title and url of the page
31 Select an Element from dropdown
32 Capture the screenthot
33 Close the browser
34 Note:
35
36 Public variable ( global )
37 The variables which are declared outside the method can be
38 accessible to all the methods in the same class
39
40 Ex:
41 Int x, y,z ;--------------------global variables ( public )
42 Public void add()
43 {
44 Z=x+y;
45 S.o.p(z);
46 }
47 Public void sub()
48 {
49 Z=y-x;
50 s.o.p(z);
51 }
52
53
54
55
56 Private variables ( local )
57 The varibles which declared inside the method cannot be
58 accessible to all the methods, but the declared method can
59 be accessible in the same class
60
61 Public void add()
62 {
63 Int x, y,z ;--------------------local variables ( private )
64
65 Z=x+y;
66 S.o.p(z);
67 }
68 Public void sub()
69 {
70 Z=y-x;
71 s.o.p(z);
72 }
73
74
75 package CallingMEthods;
76 import [Link];
77 import [Link];
78 import [Link];
79 import [Link];
80 import [Link];
81 import [Link];
82 import [Link];
83 import [Link];
84
85 public class Class_A {
86
87 WebDriver d;
88 public void Opening_Browser()
89 {
90
91 [Link]("[Link]","C://chromed
92 [Link]");
94 d=new ChromeDriver();
95 [Link]("[Link]
96
97 [Link]([Link]("/html/body/div/div[1]/div[3]/div/di
98 v/form/div/div/span/span/button")).click();
100 [Link]().window().maximize();
101
102 }
103 public void title()
104 {
105 [Link]([Link]());
106
107
108 }
109 public void url()
110 {
111 [Link]([Link]());
112
113 }
114 public void searching()
115 {
116
117 [Link]([Link]("searchDropdownBox")).sendKeys("Book
118 s");
120 }
121
122 public void screenshot() throws IOException
123 {
124 File
125 scr=((TakesScreenshot)d).getScreenshotAs([Link]);
126 [Link](scr,new File("D://[Link]"));
127
128 }
129 public void close()
130 {
131 [Link]();
132
133 }
134
135
136 public static void main(String[] args) throws IOException
137 {
138 Class_A a1=new Class_A();
139 a1.Opening_Browser();
140 [Link]();
141 [Link]();
142 [Link]();
143 [Link]();
144 [Link]();
145
146 }
147 }
148
149
150