-
Notifications
You must be signed in to change notification settings - Fork 3
/
Interview-Question.txt
2532 lines (1747 loc) · 84.7 KB
/
Interview-Question.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
============================ [ 22-JUNE 2022 ] ======================================
-------------- SELENIUM INTERVIEW QUESTIONS - -----------------
QUESTION:
DIFFERENCE BETWEEN Webdriver driver = new ChromeDriver(); AND ChromeDriver driver = new ChromDriver(); ?
ANSWER:
*> If we are using the ChromeDriver driver it means we are invoking and act onlt the which implemented by the ChromeBrowser and Supported By ChromeBrowser;
*> If We are using the WebDriveer driver it means we are creating an instance of WebDriver interface and casting it to ChromeDriver class.
driver object here has the access to the methods driver object here has the access All the methods of ChromeDrover
Of ChromeDriver which are defined in the WebDriver Interface
Iska use kr k ham 1 code ko multiple browser m run kr skte h Iska use kr k ham 1 code ko only Chrome m run kr skte h kyu ki hm yha par
Like: WebDriver driver = new FireFoxDriver(); ChromeDriver class ko denote kr re hai.
WebDriver driver = new ChromeDriver();
Yha par hm WebDriver Class k methods ko use kr skte hai Yha pa only ChromeDriver class k methods ko use kr skte hai.
or code only chrome m chlega
WebDriver Class hai or ChromeDriver Interface ChromeDriver Class hai or ChromeDriver Interface
*> Yha pr WebDrivere class ChromeDeriver() class m extendshoti h . or hm WebDrivere driver = new ChromeDeriver(); krte h , mtlb hm WebDriver ki properties access kr reh . Or ChromDriver driver =new ChromDriver() krenge to mtlb ChromeDeriver class ki properties access kr re h tabhi esa krne se test only chrome m chlte h .
*> WebDriver() parent class h or is classko sab classess access krti h , like Firefox chrome, edge etc.. tb Webdriver likhne se test sare browser m chlta h .
*> Is consept ko upcasting bhi khte h .
Note: Webdriver driver = new ChromeDriver() isme jitne bhi function ChromeDriver interface k ander define honge.
un sab ko ham webdriver class ka object bana kar access kr skte h
QUESTION:
DIFFERENT BETWEEEN driver.close() AND driver.quite(); ?
ANSWER:
*> driver.close(); will close the current tab. and driver.quite(); will close the complete browser opened by selenium automation.
-> driver.close(); will close only the current tab.
-> driver.quit(); will close all tabs which opened by selenium
QUESTION:
WHAT IS Strin IN JAVA ?
ANSWER:
*> String is a Object that Represent the sequance of the charactrs.
QUESTION:
HOWMANY WAYS WE CAN DEFINE String?
ANSWER:
We can Decleare String in 2 Ways.
1. Literal string. [ String name = "Sanju ji"; ]
2. Useing new newKeyword [ String name = new String("Sanju ji"); ]
QUESTION:
DIFFERENT BETWEEN DEFINE String USING Literal way and USING new keyword ?
ANSWER:
*>If we are defineing String Like this [ String name ="Sanju"; ]
*>In this case if we are defining the 2 string variables with the same vale then java will not create 2 different-2 mamory for both variables.
Java will Create Only one memory allocation and denote the value of 1st variable for the 2nd variable.
QUESTION:
HOW TO PRINT A GIVEN STRING IN REVERS ORDER ?
ANSWER:
String S = "Selenium";
**-> for(int i=s.length()-1; i>=0; i--)
{
System.out.println(s.charAt(i));
}
QUESTION:
DIFFERENT BETWEEN Public void FunctionName() and Public Static functionName() ?
ANSWER:
-> We cal call a STATIC method without creating a object of the class .
-> we can call a nonStatic function only create a object of the calss .
QUESTION:
WHAT IS MEANS OF element intercepted exception in selenium ?
ANSWER:
-> Ye error tb aati h jb hm koi operation perform krte h . or vo page load hone se phle hi perform ho jata h .
-> Iske liye hme [ Thread.sleep(1000) ] ya [ driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5)); ] ka use krna hota h .
-> Is method ka use krne se jb tk page load ni ho jata tb tk selenium koi action persorm ni krega
QUESTION:
DIFFERENT BETWEEN implicitlyWait() AND Thread.sleep(1000) FUNCTION ?
ANSWER:
-> implilityWaite() tab use kr krte h jab hme kisi object ko page m load hone k liye waite krna ho h.
-> Thread.sleep(); tab use krte h jb koi object page m pahle se h or vo show ni hora h . to use show hone tk waite krne k liye ise use krte h
ANSWER:
WHAT IS REgular expression CSSselector in selenium ?
-> We can select the element by some words
Example: driver.findElement(By.cssSelector("input[type*='pass']")).sendKeys("hello");
-> button[contains(@class,'btn btn-submit')] // agr 1 element 2 class h to 1 hi likhni hoti h .
QUESTION:
If WE HAVE 2 SAME BUTTON WITH THE SAME CLASS. HOW DID WE INENTIFY WHICH ONE Y=WE NEED ?
<div class="forgot-pwd-btn-conainer">
<button class="go-to-login-btn">Go to Login</button>
<button class="reset-pwd-btn">Reset Login</button>
</div>
ANSWER:
-> In this case we need to use indexing of the element
-> //div[@class='forgot-pwd-btn-conainer']/button[1]
QUESTION:
DIFFERENCE BETWEEN ABSLUTE AND RELATIVE X-PATH ?
ANSWER:
-> Abslute X-path m hm DOM k root se child element ko likhte h one-by-one
* EXAMPLE: /html/head/body/div/h2/p/span
* or is m / ka hi use krte h.
-> Relative X-path m hm DOM se kisi bhi element ko direct access kr skte hai.
* EXAMPLE: //Div/p/span
QUESTION:
HOW CAN WE TRAVEL FROM CHIELD TO PARENT LOCTORS ? if we want to find <a> tag and we are in lOGIN button
-> <header>
<a href="#">click</a>
<div>
<button class='btn-lOGIN'>HOME</button>
<button class='btn-lOGIN'>PRACTICE</button>
<button class='btn-lOGIN'>LOGIN</button>
</div>
</header>
-> WE ARE ON LOGIN BUTTON NOW.
->Like: driver.findElement(By.xpath("//header/div/button[3]"))
*ANSWER*-->driver.findElement(By.xpath("//header/div/button[3]/parent::div/parent::header/a"))
QUESTION:
HOW CAN WE TRAVEL FROM PARENT TO CHIELD LOCTORS ?We want to find Login Button and we are in Home nutton
-> <header>
<a href="#">click</a>
<div>
<button class='btn-lOGIN'>Home</button>
<button class='btn-lOGIN'>Practice</button>
<button class='btn-lOGIN'>LOGIN</button>
</div>
</header>
-> WE ARE ON Home BUTTON NOW.
->Like: driver.findElement(By.xpath("//header/div/button[1]"))
*ANSWER*-->
driver.findElement(By.xpath("//header/div/button[1]/following-sibling::button[2]")).getText();
QUESTION:
DIFFERENCE BETWEEN driver.get(); AND driver.navigate(); ?
ANSWER:
*> driver. get() is used to navigate particular URL(website) and wait till page load.
*> driver. navigate() is used to navigate to particular URL and does not wait to page load.
*> driver.get(); can not store the session and cookies. but driver.navigate(); can store session and cookies.
*> driver.get(); ye function tab tk action perform nahi karega jab tak complete page load nahi ho jata.
*> Jb tak complete page load nahi hoga tab tk waite krta hai bina kisi extra method call kiye.
*> driver.navigate(); ye function page open hote hi action perform krna start kr deta h . complate page load hone tk waite nahi krta hai.
*> isi liye hm first time jb browser open krte hai to driver.get() ka usse krte hai.
QUESTION:
What are the new features of Selenium 4.5 ?
1. Can take a screenshot of any element.
2. Can open multiple applications in a browser at a time.[ multiple windiws and multiple tabs can opened ]
3. Relative locators.
4. Chrome Dev tools.
QUESTION:
Difference between @factory and @ Dataprovidor annotation ?
ANSWER:
*> @DataProvider gives you the power to run a test method with different sets of data,
*> @Factory gives you the power to run all methods inside a test class with different sets of data.//
QUESTION
Types of test Annotation in testng ?
1. KeyWord drivern automation testing
2. Securoty testing.
3. Integration.
4. Unit Testing.
5. SMmoke testing.
6 Regration testing
7. Performance testing
QUESTION:
How can we switch into the frame ?
ANSWER:
driver.switchTo();
QUESTION:
Difference between relative and absolute xPath ?
ANSWER:
Absolute Xpath: It uses Complete path from the Root Element to the desire element.
Relative Xpath: You can simply start by referencing the element you want and go from there
-> jb hm ABSLUTE xPath bnate h to hm head element se bottem tk jate h .
-> LIKE: head/body/div/div/div/span/b
-> OR jb hm Relative xPath bnate h tb hm elemt ko middle se bhi target kr skte h
-> Like : head/div/b
QUESTION:
Write a program in JAVA to count the repeted the similar alpabets in given string ?
ANSWER:
*> : https://github.com/SanjuDeveloper/SeleniumFullCourse/blob/master/SelinumBesic/src/String.java
QUESTION:
Why we use Static keyword in void main() function ?
ANSWER:
*> The main() method is static so that JVM can invoke it without instantiating the class
*.function m Static lgane se hme class ka object ni bnana padhta hai. direct function call ho jayega
QUESTION:
Difference between findElement and findElements ?
ANSWER:
*> findElement is used to uniquely identify a web element within the web page.
*> findElements is used to uniquely identify the list of web elements within the web pag
*>. findElement will is use to find Element on the DOM.
*>. findElements is use to get the list of the elements in DOM
QUESTION:
How can we heighlight any element in selenium ?
ANSWER:
*>. By add custom css on element using JavascriptExecutor.
JavascriptExecutor js=(JavascriptExecutor)driver;
js.executeScript("arguments[0].setAttribute('style','background: red; border:2px solid blue;')",h1);
QUESTION:
What is the dataDriven framework ?
ANSWER:
Send data on runtime using dataProvidor in testNG is call dataDriven framework
QUESTION:
Difference between hard asssersion and soft assersion ?
ANSWER:
*> A Hard Assertion is a type of assertion that throws an exception immediately when an assert statement fails
*> Soft Assertions are the type of assertions that do not throw an exception immediately when an assertion fails
[
Hard assersion m agr hm koi script run krte h to agr koi testCse fail hota h to script ka excution stop ho jata h .
Soft assersion m hme script ka output last m milta h ki kitne case pass or kitne fail hue, script ka excution ni rukta hai.
]
QUESTION:
Can we run the testNg testcases through command promt ?
ANSWER:
*> YES
QUESTION:
What is the key component of maven ?
ANSWER:
1. maven-dependency-tree -> means it contains a tree model of maven dependancy in pom.xml file.
2. maven-filtering -> Components for filtering resources
3. maven-invoker -> Fires up a Maven build in a new JVM.
QUESTION:
Why we use selenium ?
ANSWER:
*> Selenium is an open-source tool that automates web browsers.
*> It provides a single interface to u write test scripts in programming languages
*> like Ruby, Java, NodeJS, PHP, Perl, Python, and C#,
QUESTION :
WHAT IS HYBRID FRAMEWORK ?
ANSWER:
Hybrid framework means use the test data and test keyword are in external file.
*> Like: dataDriven frameword -> test data fron json file. of hashmap and object..
*> Keyword driven dramework -> Test data from excel file. text file etc...
QUESTION:
WHAT IS Behaviour Data Driven (BDD) Frameworks:
ANSWER:
Means test case are write in s simple language like in englist.
*> The test case are easy to understand. for non tech person. like , BDE, product owner etc.
*> Like CUCUMBER. ,Specflow, Testsigma etc.
QUESTION:
What is Parent-Child x-Path ?
ANSWER:
*> in this xpath, we need to write the xpath of parent node first and then the xpath of child node.
*> "//div[@id='ParentElemet-Ki-Id'] //a[@value='Child-ka-Xpath']"
[
=>Is m hme phle paren element ka xPath dena hona h then child Element ka xPath
=> Example: driver.findElement(By.xpath("//div[@id='ParentElemet-Ki-Id'] //a[@value='Child-ka-Xpath']")).click();
]
QUESTION:
Types of waites in selenium ?
ANSWER:
-> implicitlyWait
-> explicityWaite
-> Thread.sleep // Ye JAVA ka part h selinum ka ni h ye function
->Flueant aite // agr time 20 second ka h to hm fluent wait m 10 pass kr denge to ye every 10 min bad check krega ki elemet visible h ya ni.
QUESTION:
Difference Beetween implicitlyWait and ExplicityWaite ?
ANSWER:
*> IF we are using implicitly waite then the browser will wait for the same time frame before loading every web element
*> The explicitly waite can implement only for specific element.
-> implicitlyWait globally declear hota h , 1 bar declear krne se vo complete page k liye work krega
-> ExplicityWaite alag-2 elements k liye lgana padhta h .
QUESTION:
Difference between Thread.sleep AND implicitlyWait ?
ANSWER:
*> The implicitlyWait will move for next line of code to execute if it found eny element before the given time duration.
*> The thread.sleep will waite for complete time duration even it found the elemment befor the given timeduration.
-> Thread.sleep m hm jitna time set krte h vo utne time page tk waite krta h chahe page load m time kam bhi lg ra .
-> implilityWaite only utna hi waite krega jitna loading m lgega chahe time hne jada bhi diya h tb bhi.
-> implicitlyWait tb page load hone m time lgta h tb waite krta h or thread.sleep agr pagr load hone k bad koi responce ya dynamic data load hota h us time use hota h
QUESTION:
Differecne between xPath And cssSelector ?
ANSWER:
*> In xpath we can travers backword and forword both side.
*> But in cssSelector we can oly traver forword. means parent to child.
-> xPath m hm forword or backword donu way m move kr skte h. [ fowrod-> parent to child, backword-> child to parent ]
-> cssSelector m hm only fordword move krte h mtlb parent to child ?
QUESTION:
How can we import excel file into selenium ?
ANSWER:
*> We can import excel file in selenium by Using Apache POI API librery .
QUESTION:
Difference between testNG and Junit ?
ANSWER:
*> We can do only unit testin in Junit.
*> And by using the testNg we can do aprox alltype of testing.
QUESTION:
How can we handel windows based functionality using selenium ?
ANSWER:
*> By using AutoIT tool in windows and for linux we can use the Robot class consept.
QUESTION:
TYPES OF Hard Assertion in selenium ?
ANSWER:
*> assert.assertTrue(); // accept trur
*> assert.assertFalse(); // accept false value.
*> assert.assertEquals();
[
1. assertTrue only TRUE result accept rta hai. jese if($disabled == true) { } //
-> assert.assertTrue(driver.findElement(By.id("checkbox").isSelected())); // agre ye true hua to TestCase PASS
2. assert.assertFalse(); only FALSE result accept rta hai. jese if($disabled == false) { } //
-> assert.assertFalse(driver.findElement(By.id("checkbox").isSelected())); // agre ye false hua to testCase PASS
3. assert.assertEquals(); only FALSE result accept rta hai. jese if($a == $b) { } //
-> assert.assertEquals(driver.findElement(By.id("checkbox").isSelected())); // agre ye equals hua testCase PASS
]
QUESTION:
HOW CAN WE CLICK ON JS ALERT IN SELENIUM ?
ANSWER:
*> by using switchTo().clert(); method.
FOR EXAMPLE:
1 IF we ant to click OK , YES OR CONFIRM ? // driver.switchTo.alert().accept();
2. IF we ant to click Cancel , No // driver.switchTo.alert().dismis();
Question 1:
In order to identify static dropdowns, what class and methods are used in Selenium Web Driver?
ANSWER:
CLASS : select
METHOD: deselectByVisibleText , deselectByindex Etc.
Question 2:
In a webpage, if there are three elements with same xpath value,
how do we explicitly identify the third element on the page with the help of index. Let us consider,
the matching xpath be //input[@name=’Selenium’]
ANSWER: (//input[@name=’Selenium’])[3]
Question 3:
How do count number of checkboxes on a webpage?
ANSWER: driver.findElements(By.cssSelector(“input[type=’checkbox’]”)).size();
Question 4:
How do we capture the message visible on the alerts?
ANSWER:
(driver.switchTo().alert().getText()
Question 5:
Identify the method used in Selenium WebDriver to get the status of the radio buttons or checkboxes (selected or not).
ANSWER:
By usine isSelected(); method.
Question 6:
Identify the method used in Selenium WebDriver to verify the presence of a web element within the web page.
ANSWER:
By using isDesplayed(); method.
Question 7:
What is the return type of the isEnabled () method?
ANSWER:
Boolean;
Question 8:
How to handle chrome browser notifications in selenium ?
ANSWER
By using ChromeOptions() CLASS.
EXAMPLE:
ChromeOptions o = new ChromeOptions();
o.addArguments("--disable-notifications");
Question :
WHAT IS FLUENT WAITE IN SELENIUM ?
ANSWER:
1. Fluent waite find the webElemet in repeatly on regular interval of time until the timeout or till the object found.
2. Fluent waite hm time k sath 1 pooling time bhi pass krte h , for Example hm tome 30sec or polling time 3sec diya h to
. selenium har 3sec bad element ko found krega. 30sec tk.
3. Fluent waite Waite_interface ko use krta h . or implecit or explict wate WebDriver interface ko use krte h .
SYNTAX:
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
.withTimeout(Duration.ofSeconds(30s))
.pollingEvery(Duration.ofSeconds(5s))
.ignoring(NoSuchElementException.class);
1. Waite interface h Or FluentWaite class hai.
2. poolingEvery mtlb ki selenium har 5sec bad webelement ko find krega
3. ignoring mtlb agr 30sec se phle NoSuchElementException ki exception ayegi to selenium use ignor krega
Example code: https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/support/ui/FluentWait.html
VIDEO NO. 84
Question 1:
How to achieve synchronization in Selenium WebDriver?
.
ANSWER: implicit and Explict waite
Question 2:
Identify the incorrect statement about implicit wait in Selenium WebDriver.
ANSWER:
If the maximum implicit wait time is 10 seconds, the web driver waits for the entire 10 seconds even if the object is available at the 3rd sec.
Question 4:
Identify the correct syntax for declaring implicit wait in Selenium WebDriver.
Answer:
driver.manage().timeouts().implictlyWait(5,TimeUnit.MILLISECONDS)
Question 5:
Which class is responsible to achieve explicit wait in Selenium WebDriver?
ANSWER
WebDriverWait w = new WebDriverWait(driver,5)
Question 6:
Identify the incorrect method to implement explicit wait in Selenium WebDriver.
ANSWER:
frameToBeAvailable
QUESTION:
How can we handle mouse/keyboard events in selenium ?
ANSWER:
By using the actions class? // Actions a = new Actions(); // a.functionName();
QUESTION:
WHOE CAN WE PRESS ANY KEYBOARD KEY IN SELENIUM ?
ANSWER:
By using keyDown(key.SHIFT); // SHIFT is key name
QUESTION:
HOW CAN RIGHTCLICK ON ANY ELEMENT IN SELENIUM ?
ANSWER:
By using contexClick(); method actions class.
Question:
How can we handle multiple windows/tabs in selenium?
ANSWER:
By using getWindowHandles(); method.
1. getWindowHandles(); ki help se hm 1 tab/window se dusre window/tab m shotch kr skte h .
2. Iske liye hme iterator(); function ka use krna hota hai.
3. iterator(); function hme sari chile window ki id deeta hai.
4. iterator() class ka object bna k hm obj.next(); function se hm next tab/windos m switch kr skte hai.
VIDEO NO. 88 in udemy
QUESTION:
WHAT ARE iterator() ?
ANSWER:
*> By using the itrator method we can travers the next artical.
iterator class ka use kr k hm next artical ko read kr skte h.
Next artical means next tab in browser ya next row in exel or any next data ect
QUESTION:
HOW CAN WE SWITCH INSIDE A Iframe IN SELENIUM?
ANSWER:
By using switchTo.frame('framePath'); function.
QUESTION:
HOW CAN WE Go OUTSIDE OF THE Iframe IN SELENIUM ?
ANSWER:
By using switchTO.defaultContent();
QUESTION:
HOW CAN WE PERFORM Drag and Drop action in SELENIUM?
ANSWER:
By using dragAndDrop() function of Actions class. // We need to pass the path of source and destination
Example: actionObject.dragAndDrop(sourcePath,targetPath).build.perform();
QUESTION:
Which class is responsible for the performing mouse and keyboard interactions with Selenium?
ANSWER:
Actions.
QUESTION:
How to perform right click with the help of actions class in Selenium?
ANSWER:
Actions a = new Actions(driver)
a.moveToElement (driver.findElement(By.id(“name”))).contextClick().build().perform()
QUESTION:
How to enter text ‘Hello’ in capital letters help of actions class in Selenium?
ANSWER:
Actions a = new Actions(driver)
a.moveToElement (driver.findElement(By.id(“name”))).click().keyDown(Keys.SHIFT).sendKeys(“Hello”).build().
NOTE:
*> Actoins a = new Actions(driber);
*> a.keyDown(keys.SHIFT).sendKeys("sanju"); -> Mtlb ki shift key press kr k rkhega fir value enter hogi.
*> a.(Keys.chord(Keys.SHIFT + Keys.CONTROL + "s") -> Mtlb ki 1 sath multiple keys press hongi. Like : CTRL+S OR CTRL+SHIFT+S
QUESTION:
Which method is used to store multiple child windows in Selenium?
ANSWER:
getWindowHandles();
QUESTION:
How to navigate to the parent window when there are multiple windows?
ANSWER:
Set<String> windows = driver.getWindowHandles(); //[parentid,childid,subchildId]
java.util.Iterator<String> it=windows.iterator();
String parentId = it.next();
driver.switchTo().window(parentId);
QUESTION:
How can we identify frames in Selenium?
ANSWER:
By its ID,INDEX,webElemet.
QUESTION:
Name the Java collection framework used to store window ids.?
ANSWER:
set.
QUESTION:
Differecne between BlackBox And WhiteBox testing?
ANSWER:
QUESTION:
What are the component of selenium?
ANSWER:
1. selinum IDE.
2. SELENIUM WEBdriver.
3. selenium rce.
4. selenium grid.
QUESTION:
HOW CAN WE COUNT THE LINKS IN THE WEB PAGE?
ANSWER:
By using the driver.findElements(By.tagName("a")).size(); function.
QUESTION:
How can we handle https SSL certificate in Automate Browser?
ANSWER:
By using the ChromeOptions class. ChromeOptions option = new ChromeOptions();
VIDEO N0. 104:->
=> ChromeOption class se hm chrome k behivior ko change kr skte h [ chrome browser behivior ko customize kr skte h ]
1. Windows popUp disable
2. ByPass SSL // unsecure URL
3. Set proxt
4. Download path set [ ki file download hone k bad kha p save hogi ]
5. Download extensions
QUESTION:
What is regular expression ?
ANSWER:
input[name*='pas'] // jb hm is type ka Locator use krte h to ise regular exresiion khte h [regular expression locator m mtlb * ka use hoga]
QUESTION:
WOH CAN WE DELETE COOKIES OF BROWSER ?
ANSWER:
By using [ driver.manage().deleteAllCookies(); ]
QUESTION :
HOW CAN HIT URL AND GET STATUS CODE OF THE SAME?
ANSWER:
By using HttpURLconnection() method.
Question 1:
Name the class to customize the Chrome browser.?
ANSWER:
By iseing ChromeOptions(). class.
Question 1:
Identify the method to maximize the browser window.
ANSWER:
driver.manage().window().maximize();
Question :
How to delete cookies in Selenium Web Driver?
ANSWER:
1. driver.manage().deleteCookieNamed(“sessionId”)
2. driver.manage().deleteAllCookies()
Question :
How to capture screenshots with Selenium Web driver?
ANSWER:
File s = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(s, new File (“C:\\Users\\Screenshots\\screenshot.png”));
Question :
How to identify broken links in Selenium Webdriver?
ANSWER:
Get Status codes of links to decide if they are broken
@ => WHAT IS JAVA STREAM ?
-> JAVA stream m helper function hote h. jin ka use kr k hm looping consept ko avoide kr skte h.
> jese map(); filter(); etc.
-> Agar hme kisi elemtnts m loop chalana h to hm java stream ka use kr Without loop k bhi logic likh skte h .
SYNTAX:
List<WebElement> rows = driver.findElements(By.xpath("//tr/td[1]"));
price = rows.stream().map(s.s->getText).collect(Collectors.toList());
{
* Is code m hm rows m jitne bhi element aa rhe hai un sab ko map kr k every element ka price list m store kr rhe hai .
* rows m jitne bhi element aa rhe h vo sab s m store ho rhe h fir hm us element ka text list m store kr rhe hai.
}
QUESTION:
WHAT ARE Relative Locators IN SELENIUM ?
ANSWER:
1. Relative Locators Selenium 4 m introduce hue the.
2. Relative locators tb use hote h jb kisi element k tagName k alava koi or attribute ni hota h.
-> is case m hme element ka path search krna thoda hard hota h to hm Relative Locators ka use kr lete h .
3. Relative locators Only tagName k sath kaam krta h .
4. Relative Locators m 4 function hote h. 1. above, 2. blew, 3.toRightOf, 4. toLeftOf.
Syntax:
WebElement nameEditBox =driver.findElement(By.cssSelector("[name='name']")); // find the name input field.
System.out.println(driver.findElement(with(By.tagName("label")).above(nameEditBox)).getText());//find label which is above the name inputBox
QUESTION:
HOW CAN GET Height and Width of element ?
ANSWER:
WebElement name = driver.findElements(By.className("name"));
name.getRect().getDimension().getHeight();
=> WHAT IS TESTNG ?
-> testNG 1 automation framework h jiks use kr k hm testCses ko handle kr skte h. ( ki knsa tes case kb run krna h .ya kitne test case run krne ki tne ni krne h ye sab .)
-> TestNG m testcase testng.xml file se run hote h .
** => testng.xml file info
-> <suite name="Suite"> is tag k ander set of packages hote h . iske ander multiple packages hote h.
-> <test thread-count="5" name="Test"> is tag k ander multiple class hoti h.
-> <class name="TestNG.test"> iske ander methods ko include or exclude krte h .
QUESTION ?
WHAT ARE TESTNG Annotation ?
1. @BeforeTest -> jis function m ye annotation lgega vo function xml suite k test se phle run hoga.
2. @AfterTest -> jis function m ye annotation lgega vo function xml suite k test k bad run hoga.
3. @beforesuite -> jis function m ye annotation lgega vo function suite se phle run hoga
4. @aftersuite -> jis function m ye annotation lgega vo function suite suite k bad run hoga.
5. @beforeclass -> jis function m ye annotation lgega vo function us class k sabhi functions se phle run hoga.
6. @afterclass -> jis function m ye annotation lgega vo function us class k sabhi functions k bad run hoga.
7. @aftermethod -> jis function m ye annotation lgega vo function us class k every function k bad run hoga. [ har functionk bad run hoga ]
8. @beforemethod -> jis function m ye annotation lgega vo function us class k every function se phle run hoga. [ har functionkse phle run hoga ]
9. @Test -> ye annotation class m alfabetic order m run hote h .
QUESTIONS :
What are testng xml label annotation ?
ANSWER:
1. @beforesuite.
2. @aftersuite.
1. @beforetest.
2. @aftertest
QUESTIONS :
What are class label annotation ?
ANSWER:
1. @beforeclass.
2. @afterclass
QUESTIONS :
What are method label annotation ?
ANSWER:
1. @beforemethod.
2. @aftermethod
QUESTION:
Difference between @beforeMethod and @beforeClass annotation ?
ANSWER:
@beforeClass annotation jis function m lgega vo function class m sabs phle run hoga
@beforemethod annotation jis function m lgega vo function sabhi function k run hone se phle run hoga ,
LIKE : 1-method-annotation then functionOne , methon-annotation then functionTwo .....
=> Agr hmare pass 1000 test case h or hme 10 function run krne h to kese krenge ?
1. grouping kr dete h testcases ki .
1. Function k upar ye aayega ->
*syntax: @test({"loginGroup"})
2. Or testNg.xml file m use define krna hoga jis group ko run krna h ya ni krna h .->
* <groups><run><include name =”Login”/></run>
=> TYPES OF ANNOTATION HELPER FUNCTION IN TESTNG ?
ANSWER:
1. timeout =500
2. enabled = false
3. depandsonMethod({"method", "method"});
1* depandsOnMethod :
if we have method A and method B . and we are trying to excute method A and method A is depends on method B in this case we will
Use depandsOnMethod over method A. then the testNG excute method B first. we can pass multiple methods inside the depandsOnMethod
liek: depandsonMethod({"method", "method"});
2* enabled :
if we want to skip ant particular methos while running testng.xml file in that case we will use enabled helper function.
LIKE: disable=true or disable=false;
2* timeOut :
if we want to waite some time before execute any method in that case we will use @timeout=400 over that function.
QUESTION:
What is parameterization in TESTNG ?
ANSWER:
if we want to set any global variables, then we can set that on our testng.xml file.
LIKE : <parameter name="URL" value="https://www.facebook.com/"/>
ANd can access this URL variable on any function of suite.
before function use this keyword: @Parameters({ "URL" }) and accessit as a argument.
*. <parameter/> ko hm suite , test ya class kisi base p bhi set kr skte hai.
QUESTION.:
Agr hme kisi test case m multiple set of test data send krna h to kese kr kste h ?
ANSWER:
testNG DataProvider ka use kr k , or testng.xml file se bhi send kr skte h .
LIKE: login test case m multiple userName or Password k sath test krna h to DataProvider annotation ka use kr k send krte hai.
Question:
Parameterization kite type se kr skte hai ?
ANSWER:
1. DataProvider 2. testNG.xml
QUESTION:
Parameterization DataProvider ka use kr k kite type se kr skte h ?
ANSWER:
1. agr data small amount h to array bna k send kr dete h /
2. agr data midium h amount m h to HashMap [ array] ka use kr skte h.
3. agr data larg amount m h mtlb bhut jada data hai to json format m send krte h . [ json ki file bna k use call krte h]
QUESTION:
WHAT ARE LISTENER IN testNG ?
ANSWER:
* jb hm kisi testcase ko run krte h or hm testcase k execute hone pr koi action perform krna chahte hai to hm LITENER ka use krte hai.
* ITestLISTENER ka use krne k liye hm ITestLISTENER interface ko apni class m implement kr k uske function ko implement krte hai.
* ITestLISTENER i interface hota h usme sare function define hote h or hm unko apne according implement krte h .
* Like agr testCase fail hua to uska screenshot lena pass hone pr koi message dena ECT.
* ITestLISTENER k ande 1. onTestCsePass 2. onTestCseFiler 3. onTestCseSkip ect ye sab function hote h .
* ITestLISTENER ko use krne k liye use testNG.xml file m regester krna hota h . below code <suite k neeche aayega *
<listeners>
<listener class-name="TestNG.Listener"></listener>
</listeners>
* . NOTE : Agr imterface k methods ni milte h to . rightClick on listeners.java file and click on source-> overridemethods.
Questionh :
Whow can we run testCases paralllely using testNG?
ANSWER:
1. iske liye mne testNG.xml file m <suite> tag m define knra hota h ki kitne methods parallely run krne h or parrally test run krna h ya class.
* <suite name="Suite" paralllel="test" thread-count="6"> // test k 6-6 method parallely run honge.
2. Hm class base pr bhi testCases ko paarallel run kr skte hai.
* <suite name="Suite" paralllel="test" thread-count="6">
------------------------------ TESTNG QUESTIONS ----------------------------
Question 1:
How to run tests with TestNG framework?
Answer:
@Test annotation followed by method name.
Question 2:
Identify the incorrect statement about TestNG.
Answer:
TestNg allowes a single test from a single class file.
Question 3:
If there are three test cases in a class, method having @BeforeMethod annotation shall be executed how many times?
Answer:
three times.
Question 4:
Which helper attribute skips a particular test from execution in TestNG?
Answer:
* enabled.
Question 5:
How to retrieve a global variable defined in the TestNG xml (xml code snippet given below) to the test method?
Answer:
@Parameters({ "URL" })
@Test
public static void demo1(String siteURL) {
System.out.println("Admin login ONE parameter="+siteURL);
}
Question 6:
How many ways test methods can be run in parallel mode using TestNG?
Answer:
* Tests label * class label.
Question 7:
How to achieve parameterization with multiple data sets with multiple combinations in TestNG?
Answer:
@DataProvider
Question 1:
How to run tests with TestNG framework?
Answer:
@Test annotation followed by method name.
Question 1:
How to run tests with TestNG framework?
Answer:
@Test annotation followed by method name.
Question 1:
How to run tests with TestNG framework?
Answer:
@Test annotation followed by method name.
Question 1:
How to run tests with TestNG framework?
Answer:
@Test annotation followed by method name.
Question 1:
How to run tests with TestNG framework?
Answer:
@Test annotation followed by method name.