So now it will send the text as ‘selenium’ also and also search that text in Google by hitting enter[by using submit() method] as below:
Now we will add one more requirement, when I open the browser it should be in full screen and not part of a screen and also once the required work is done it should also close the browser[consider an example where you have 100 test, so it will keep 100 browsers open and reduce the performance of the system]. So we will just add two small steps as below:
First is ‘driver.manage().window().maximize();’ what this does is, it tells the chrome browser to manages its window to maximize it. So now when chrome browser is initialized before Google could open it maximizes it.
Second is ‘driver.close()’ , here it tells the chrome driver to close the browser of the current session and ‘driver.quit()’, here it tells chrome driver to close all of its open windows. You will understand it better when we have a child window open example further. So when we run above code it opens a browser, maximizes it, searches text ‘selenium’, hits enter, and closes the browser.
Give it a try!!
Now we will update our code in the form of methods, instead of all the code lying in a single class. Its always better to have methods calls to required methods of a class to fulfill its requirement rather than having all code bunch at one place, this what industry follows.
Maven has miraculously already helped you in creating two folder structures viz., 'src/test/java' and 'src/main/java', where 'src/test/java' is the folder where we write our test-cases and 'src/main/java' is the folder where we place our helper classes. So in order to create our test-case, right-click on folder ‘testSearch’ under 'src/test/java' and create a new class ‘FirstTest’ in it. Hope you got why we created this class in 'testSearch' folder, the simple answer is all test-cases related stuff will lie under this directory only!! So slowly you will envisage more live benefits of Maven further.
Part-1:Want to quickly become an Selenium Automation Engineer and build framework right from scratch?
Part-2:Want to quickly become an Selenium Automation Engineer and build framework right from scratch?
Part-3:Want to quickly become an Selenium Automation Engineer and build framework right from scratch?
Part-4: Want to quickly become an Selenium Automation Engineer and build framework right from scratch?
Did she really loved me....? Part-2
Did she really loved me....? Part-3
Did she really loved me....? Part-4
Did she really loved me....? Part-5
Did she really loved me....? Part-6
Did she really loved me....? Part-7
Did she really loved me....? Part-8
Did she really loved me....? Part-9
Did she really loved me....? Part-10
Did she really loved me....? Part-11
Did she really loved me....? Part-12
Did she really loved me....? Part-13
Did she really loved me....? Part-14
Did she really loved me....? Part-15[The End]
Want to own your own start-up? Want to be Richie Rich?
Hey Corona, you should go now!!
Part-1: Want Quick Divorce? Come in...: [Kahani Ghar-Ghar ki]
Part-2: Want Quick Divorce? Come in...[Kahani Ghar Ghar ki]
No comments:
Post a Comment