Selenium Framework for Beginners 8 | How to implement POM in Selenium Java

  Рет қаралды 83,486

Automation Step by Step

Automation Step by Step

Күн бұрын

Today we will learn - How to implement Page Object Model
1. How to implement POM
What is POM
Design Principle
Create separate Object Repository to store object locators
For each web page there should be a separate page class
The page class will have all object locators and preferably action methods for the corresponding page
Step 1 : Create a class for each web page
Step 2 : Add object locators
Step 3 : Add action methods
Step 4 : Create class for test case
Step 5 : Create object for page class
Step 6 : Refer action methods
Benefits of POM
Test Objects and Functions are separated for easy maintenance and keeping the code clean
Objects are kept separated from test scripts and can be used multiple times in multiple tests
Every unique object locator is created only once
Easy Maintenance and Less Rework
#SeleniumJavaFramework #SeleniumTutorials #SeleniumTraining #SeleniumFramework #SeleniumJavaTutorial #SeleniumBeginnerTraining
PLAYLISTS
SELENIUM BEGINNERS
• Selenium Beginner Tuto...
SELENIUM JAVA FRAMEWORK BEGINNERS
• Selenium Java Framewor...
JAVA
• Java
JENKINS
• Jenkins
JMETER
• JMeter Beginner
GIT & GITHUB
• Git and GitHub
DOCKER
• Docker
ROBOT FRAMEWORK
• Robot Framework Beginn...
KATALON STUDIO
• Katalon Studio
WEB SERVICES (API)
• API Web Services
Like on FACEBOOK :
/ automationstepbystep
Follow on TWITTER:
/ automationsbs
Subscribe on KZbin :
/ automationstepbystep
_______ ONLINE COURSES TO LEARN _______
automationstep...
Like, Subscribe & Share
You can support my mission for education by sharing this knowledge and helping as many people as you can
Never Stop Learning
Raghav
automationstep...

Пікірлер: 157
@Aj21093
@Aj21093 4 жыл бұрын
Hi Raghav, I never understood POM until now. Thank you so much for so easy tutorial.
@RaghavPal
@RaghavPal 4 жыл бұрын
so happy to know this Anukriti
@BK_KARIM
@BK_KARIM 3 жыл бұрын
thanks a lot .. following from tunisia 🇹🇳 🇹🇳
@RaghavPal
@RaghavPal 3 жыл бұрын
Most welcome
@jyotsanarajput3267
@jyotsanarajput3267 4 жыл бұрын
Your explanations methods are ..... no words man
@RaghavPal
@RaghavPal 4 жыл бұрын
Thanks for watching Subhash
@jyotsanarajput3267
@jyotsanarajput3267 4 жыл бұрын
Automation Step by Step - Raghav Pal hello Raghav u look so down to earth ☺️☺️ Do you give courses on the Udemy as well I mean if i have to buy...
@atuljangra9923
@atuljangra9923 4 жыл бұрын
Thank you very much for the video, In just 30 minutes explained this topic very smoothly and easily.
@RaghavPal
@RaghavPal 4 жыл бұрын
You are welcome Atul
@sairamaraju6652
@sairamaraju6652 5 ай бұрын
Ur explanation is good, but it could be way better if u have taken two pages and perform actions on both the pages, it could clear most of the doubts
@RaghavPal
@RaghavPal 5 ай бұрын
I will check this and plan. thanks for the feedback Sairamaraju
@shehryarasif7573
@shehryarasif7573 3 жыл бұрын
Thank you so much for making these videos. I learnt a great deal from your playlist on Selenium!
@RaghavPal
@RaghavPal 3 жыл бұрын
You're very welcome!
@umamahewariduraisamy7202
@umamahewariduraisamy7202 2 жыл бұрын
You are my savior! God Bless you
@RaghavPal
@RaghavPal 2 жыл бұрын
Thanks a lot Uma
@niraj8202
@niraj8202 2 жыл бұрын
Thanks for this. I find your videos very helpful and easy to understand.
@RaghavPal
@RaghavPal 2 жыл бұрын
Most welcome Niraj
@myWayIn619
@myWayIn619 3 жыл бұрын
For anyone running Junit - place the tag (@Test) after the class then next place the method; & for (WebDriver driver = null;) just remove the (static) and the value ("Null") then next place it under the method, hope this helps! Shout out to Raghav Pal!!! Great explanation! @Automation Step by Step - Raghav Pal
@RaghavPal
@RaghavPal 3 жыл бұрын
Thanks for sharing Frank
@myWayIn619
@myWayIn619 3 жыл бұрын
@@RaghavPal Thank you man
@codezamacodinglabs
@codezamacodinglabs 2 жыл бұрын
Thanks to you and Raghav.
@sairammadipalli2600
@sairammadipalli2600 2 жыл бұрын
Really thanks ..............
@RaghavPal
@RaghavPal 2 жыл бұрын
Most welcome Sairam
@anandyashwanth9807
@anandyashwanth9807 4 жыл бұрын
Loved your explanation method raghav sir . Thanks for helping us out.
@RaghavPal
@RaghavPal 4 жыл бұрын
You're welcome Anand
@subhadeepchatterjee7439
@subhadeepchatterjee7439 Жыл бұрын
Thank you it is perfect n helpful
@RaghavPal
@RaghavPal Жыл бұрын
Most welcome Subhadeep
@durgasree9765
@durgasree9765 3 жыл бұрын
awesome and simple explanation
@RaghavPal
@RaghavPal 3 жыл бұрын
Glad it was helpful!
@jamaloubaouih2571
@jamaloubaouih2571 4 жыл бұрын
Thank you very mutch
@RaghavPal
@RaghavPal 4 жыл бұрын
You are welcome
@seqthomas1345
@seqthomas1345 2 жыл бұрын
Very helpful videos, thank you! It might help a few people if you were to add comments as you went through these.
@RaghavPal
@RaghavPal 2 жыл бұрын
Glad it was helpful!
@Glowvation-7
@Glowvation-7 2 жыл бұрын
You are truly awesome the way you explained topic is splendid. Could you please make one selenium project using Intellij.
@ahmettemel8245
@ahmettemel8245 3 жыл бұрын
very useful thank you Raghav
@RaghavPal
@RaghavPal 3 жыл бұрын
Always welcome
@rotrose7531
@rotrose7531 4 жыл бұрын
Thank you greatly!
@RaghavPal
@RaghavPal 4 жыл бұрын
You're welcome Rose
@sagarsjdjfn
@sagarsjdjfn 3 жыл бұрын
hi got the point that for maintainability and decent view we use POM. my point is we are not developers - if i am alone working on this then why to do same thing in decent way - i know the indecent way and i am fine with everything in main method jumbled up. I will give u the credits that u explained it in really good way thanks but my point is not to work extra.
@RaghavPal
@RaghavPal 3 жыл бұрын
Hi Sagar, even if you are working alone, still having a proper structure will help you in future, You can decide based on your scneario
@volodymyrdrobko659
@volodymyrdrobko659 5 жыл бұрын
Your videos are the best materials I could search in KZbin so thanks a lot but why don't you use camel case in your methods and variables naming? There are java code convention rules for naming. It is really annoying to work with people in real life projects that name their methods and variables like they want.
@RaghavPal
@RaghavPal 5 жыл бұрын
Feedback taken Vova. I will check on that
@zhengzixiang7052
@zhengzixiang7052 5 жыл бұрын
Thank you :)
@RaghavPal
@RaghavPal 5 жыл бұрын
You're welcome Zheng
@aravindhram308
@aravindhram308 5 жыл бұрын
Hi Raghav I am using pom design with Data driven(Apachi POI) in Testng using java. i have three classes 1. ShopSearchPage 2. ShopListPage 3.ShopDetailPage My Scenario is i am having a shop search page in that user enters shop location details and click enter now the application navigate to shop list page in that application shows all shops which falls inside that search location when the user can click the correct shop, the application navigate to the shop details page . By using Testng, pom, data provider i am able to accomplish shopsearch page but i face obstacle in Shop list page. As per the POM pattern i create separate class for ShopSearchPage and used data provider working fine, for 10 records set or many but for Shop list page i am using @BeforeMethod inside that i implement all the navigation steps such as launch browser and enter the ShopSearchLocation datas, here is the problem i face , i cannot use data provider inside @Beforemethod , application works only when all datas are hard coded but what i need is when i give 10 shop location datas in excel , the application has to launch browser, upload shop search data in ShopSearchPage and then navigate to the shoplist page, so that in the ShopListPage i can validate or do some test operation and click the appropriate shop. This above operation has to be done in second class that is in ShopListPage if this obstacle is overcome i can use the same approach for ShopDetail page also Please assume all test are run by using separate test classes which includes many @Test methods. CAN YOU HELP ME ON THIS. I really appreciate your help Thanks in Advance
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Aravindh, TestNG "@before" methods cannot be used directly with a @DataProvider. @Factory however can be used to accomplish the initial, data-driven setup with a @DataProvide. See this stackoverflow.com/questions/35893294/dataprovider-with-before-testng
@ashwajitthukral9101
@ashwajitthukral9101 6 жыл бұрын
Suppose we have 20 pages to test in a website and we have created 20 separate Object Repository to store object locators and preferably action methods for the corresponding page. My question is still we need only one class to test all the test cases of 20 pages? Or we need number of classes for the test cases to test all the 20 pages , if yes then how we will run the multiple test classes at once to cover all the 20 pages. Thank you so much for your effort!
@RaghavPal
@RaghavPal 6 жыл бұрын
Hi Ashwajit, according to POM principle, you need to create separate classes to store objects and actions per page. After this you can create tests the way you want. Having tests in separate classes will increase readability and management, but you can keep in single class as well.
@ashwajitthukral9101
@ashwajitthukral9101 6 жыл бұрын
Thankyou so much Raghav for your reply.. Your tutorials are simply superb ! Keep up the great work.
@testview9196
@testview9196 4 жыл бұрын
Hi Raghav, If values are available in a table in a webpage and we need to select row values dynamically based on input value and do actions(we need to iterate rows to find the element in a table). How to implement this in POM. Thanks, Kumar.
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi, you will need to add locators for web table and a loop to iterate over it. As of now I do not have a specific video for this. Will plan. For now pls take online help
@testview9196
@testview9196 4 жыл бұрын
@@RaghavPal Thanks alot Raghav.
@meditationandrelaxationmus741
@meditationandrelaxationmus741 3 жыл бұрын
very nice videos helped me in framework development driver instance needed by all test cases so should we put in a separate util class will that make it handy for all the test classes
@RaghavPal
@RaghavPal 3 жыл бұрын
Yes you can do that
@Bulleteerism
@Bulleteerism 4 жыл бұрын
Hi Raghav, will it be possible for you to create a tutorial for POM with TestNG ? Or is there an existing one for the same ? Regards
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi, you will find it in the same playlist. In TestNG videos I have used the POM approach
@anthonydarkwah8996
@anthonydarkwah8996 4 жыл бұрын
Hi Raghav, thank you very much for the videos, it's very very helpful, I am recently facing reCAPTCHA issues with chrome, please how do I solve this issue?
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Staki, Captcha is to prevent robots or automated scripts mimic humans. So ideally we should not automate Captcha, However there are ways to handle it. I will say check the following 1. How imp is to automate this scenario 2. Check the time and effort required 3. Check with your dev team if Captcha can be disabled in testing env 4. Check with your team if a static Captcha be provided in QA env
@anthonydarkwah8996
@anthonydarkwah8996 4 жыл бұрын
@@RaghavPal Thanks Raghav
@eamonharvey
@eamonharvey 6 жыл бұрын
This is a great tutorial and one that i go back to and use as a guide to creating most of my scripts! Do you have any tutorials that show more complex methods than the basic click and senkeys?
@RaghavPal
@RaghavPal 6 жыл бұрын
Hi Eamon, thanks for the message. You can check other videos here - automationstepbystep.com/ui-testing/
@kshipra4504
@kshipra4504 2 жыл бұрын
If there is a logout button or navigate link, it is common in all the pages. On which page we locate this web Element?
@RaghavPal
@RaghavPal 2 жыл бұрын
Hi Kshipra, in that case you can keep the logout object in home page
@kshipra4504
@kshipra4504 2 жыл бұрын
@@RaghavPal Hi Raghav!! Is there any specific reason for keeping it in Home page? Then, how it can be accessed on other pages?
@RaghavPal
@RaghavPal 2 жыл бұрын
Basically we just try to keep it in a way that others can find it easily
@kelvinspace9922
@kelvinspace9922 2 жыл бұрын
Kudos to Raghav
@RaghavPal
@RaghavPal 2 жыл бұрын
Thanks
@sharanarani
@sharanarani 3 жыл бұрын
Hi I am a beginner in learning framework. I found this view helpful but now I am stuck. How to handle tables in POM? for example I have a dynamic table and I have to select a particular table value upon clicking it redirects me to a file. Please help me As soon as possible
@RaghavPal
@RaghavPal 3 жыл бұрын
Hi Sharana, POM is for design and structure, it does not interfere with your coding or functionality, You will just need to create the function to handle your scenario and can put this function in the Page Class for that specific webpage
@sharanarani
@sharanarani 3 жыл бұрын
@@RaghavPal Thanks a lot.
@alohaqa7731
@alohaqa7731 5 жыл бұрын
Hi Raghav, I am using page object model and according to it I should have separate pageobject class for each page and a page test case class for page object class. So here comes my concern do I need to instantiate browser in each test case class. For example I have two test case classes TC1 and TC2. So I'll be instantiating browser for both TC1 and TC2, is it correct approach ?
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Aloha, you can create a base class and make it abstract and then make this class as base class for all test classes.
@alohaqa7731
@alohaqa7731 5 жыл бұрын
@@RaghavPal Thank you :)
@ZafarDidit
@ZafarDidit 5 жыл бұрын
Hi Ragav, I could not find in your videos about how to Assert errors if displayed on the webpage, let say when I log in with invalid credentionals, if you already have this video please share the link.
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi, you can check all videos here - automationstepbystep.com/online-courses/
@gvvprasad4744
@gvvprasad4744 5 жыл бұрын
Hi, how to return multiple variables values from the same method without creating a different method for each field.
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Prasad, although I am not sure the context where you want to use it, but as a programming rule you cannot return multiple values, as a workaround you can return a list or map etc and then take out values from it.
@volodymyrdrobko659
@volodymyrdrobko659 5 жыл бұрын
If there are several page elements with mainly the same path but have different text you can create a constant and use it for more locating more than one element. It will looks like this: private static final String GRID_HEADERS = "//div[contains(@class, 'x-grid')]//span[text()='%s']"; and then in method - public boolean isGreedHeadersPresent(List headers) { boolean status = true; try { headers.stream().forEach(header -> driver.findElement(By.xpath(String.format(GRID_HEADERS, header)))); } catch (NoSuchElementException e) { status = false; } return status; }
@cristiancruciani3603
@cristiancruciani3603 2 жыл бұрын
Hello good video amigo!!. I come from your POM video with python, can you make another class with the locators in java? as you did in pithon and it was more orderly and structured. is this posible in java?
@RaghavPal
@RaghavPal 2 жыл бұрын
Yes, you can do
@rahulray4189
@rahulray4189 4 жыл бұрын
Hi Raghav , any downside of adding action methods only the test case and not in the page class ?
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Rahul, it may become little difficult to manage and update in case you have used the action method in multiple test cases. The reason we put objects and actions of every page in separate class is that if you have to make any changes, you will have to do at a single location and it will be referred from here to all the tests wherever it is used.
@rahulray4189
@rahulray4189 4 жыл бұрын
@@RaghavPal Got it. So basically depending upon the test scenario we need to create our repository. It might/might not be a mandatory requirement ,hope i`m getting the clear picture. Please advice.
@RaghavPal
@RaghavPal 4 жыл бұрын
Yes, go as per your needs
@samarthjain5170
@samarthjain5170 3 жыл бұрын
Hi Raghav, I have one scenario, where I have n number of testcases belonging to same module. Each testcase accept diff number of parameter how to execute and pass those parameter to test method so we can execute them sequentially? TIA
@RaghavPal
@RaghavPal 3 жыл бұрын
Hi Samarth, you can use data driven testing and can also check TestNg dataprovider, there is a video on that
@samarthjain5170
@samarthjain5170 3 жыл бұрын
@@RaghavPal each and every method have different number of parameters and dataprovider will work on same testcases again and gain. My requirement is to run testcases sequentially
@RaghavPal
@RaghavPal 3 жыл бұрын
I will need to check on this in detail
@samarthjain5170
@samarthjain5170 3 жыл бұрын
Hi Raghav, Can you please make a video on it TIA
@samarthjain5170
@samarthjain5170 3 жыл бұрын
@@RaghavPal Hi Raghav, Any updates?
@9745754904
@9745754904 5 жыл бұрын
If there are 1000 pages,do we need to create 1000 page classss and corresponding 1000 test classes,
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Jino, Page Object Model principle is used so that it is easier, faster & efficient to work with objects or actions whenever there is any change or maintenance required. Now you can use it in a way that makes most sense to you. In case of big application with 1000 of pages, you can categorize your pages like User pages, Product Pages etc and create a single class per category. The idea is that it will be easy & fast to locate and change if required.
@9745754904
@9745754904 5 жыл бұрын
@@RaghavPal ok for.big applications we can create a single class and place locators of multpile.pages in it otherwise we can crrete each page class for each page
@RaghavPal
@RaghavPal 5 жыл бұрын
Yes, you can do the categorizations as per your need and as per the best practices
@DucNguyen-xn5bd
@DucNguyen-xn5bd 5 жыл бұрын
it base on how you organize your page structure bro. You can collect into category as Raghav advice, just do what make your structure easier.
@greedyboi1
@greedyboi1 5 жыл бұрын
Do you have a video showing how to use this with TestNG annotations? I'm having issues with the objects doing their job when the code is run as TestNG but when I run as a class it works...any tips please?
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi can check testng videos in playlist automationstepbystep.com/online-courses/
@dreamsapcat
@dreamsapcat 2 күн бұрын
I am getting error Error message displayed when opening Eclipse: "An error has occurred" Can you reply tome please
@RaghavPal
@RaghavPal 19 сағат бұрын
First, check the log file - it's usually in your workspace directory. That'll give you the real scoop on what's going wrong If that doesn't help, try these quick fixes: New workspace: Sometimes starting fresh helps. Java checkup: Make sure you have the right version and Eclipse is using it. Plugin problems: Did you install anything new lately? Try disabling it. Memory boost: Give Eclipse more RAM in the eclipse.ini file. -
@PritishRastogi
@PritishRastogi 6 жыл бұрын
@3:14 min: Why are we defining locator again when we already did in different class GoogleSearchPage can't we just all the locators from there? if we define here and suppose id get change then we have to do the changes in 2 places. then how is this efficient?
@RaghavPal
@RaghavPal 6 жыл бұрын
Hi Pritish, This is the 2nd way of POM, you will not require the previous class here. Here is the previous video of this series - kzbin.info/www/bejne/Y2GpXox4draXfac You can get Complete Playlist - automationstepbystep.com/ui-testing/
@jonkc3635
@jonkc3635 5 жыл бұрын
​@@RaghavPal I like this method because the locators are well organized at the top of the class.
@nistan5404
@nistan5404 4 жыл бұрын
@@RaghavPal Hi Raghav, I like the 1st way of POM method in previous session and it was very easy...Is it necessary to learn second one ? During learning of second POM method I m getting confused little bit why we using locators "By...." on the top and why we are using constructor in POM what is the reason behind it please explain.
@Abhinav-kw5qx
@Abhinav-kw5qx Жыл бұрын
hello sir how can we handle windows or tabs in a framework i have tried to find out but failed please help me.
@RaghavPal
@RaghavPal Жыл бұрын
Abhinav There are a few ways to handle windows or tabs in a Selenium Java framework One way is to use the `getWindowHandle()` method to get the ID of the current window. You can then use the `switchTo()` method to switch to the desired window. For example, the following code will switch to the second window: ``` String currentWindowHandle = driver.getWindowHandle(); for (String windowHandle : driver.getWindowHandles()) { if (windowHandle != currentWindowHandle) { driver.switchTo().window(windowHandle); break; } } ``` Another way to handle windows or tabs is to use the `WebDriverWait` class. The `WebDriverWait` class allows you to wait for a certain condition to be met before continuing. For example, the following code will wait for the second window to open before switching to it: ``` WebDriverWait wait = new WebDriverWait(driver, 10); wait.until(ExpectedConditions.numberOfWindowsToBe(2)); driver.switchTo().window(1); ``` Finally, you can also use the `Tab` class to handle tabs. The `Tab` class provides methods for opening, closing, and switching between tabs. For example, the following code will open a new tab and switch to it: ``` Tab tab = new Tab(driver); tab.open(); driver.switchTo().window(tab); ``` Which method you use will depend on your specific needs and preferences. If you only need to handle a few windows or tabs, then the first method is a good option. If you need to handle a large number of windows or tabs, then the second method is a good option. If you need to handle tabs specifically, then the third method is a good option. I hope this helps
@DucNguyen-xn5bd
@DucNguyen-xn5bd 5 жыл бұрын
Something wrong with my Eclipse, I follow 100% the same code as your instruction, but when I call GoogleSearchPageObject abc = new GoogleSearchPageObject(driver). The error message display to tell me that I must import the GoogleSearchPageObject. This error make me confuse because GoogleSearchPageObject is public, it should be seen by anywhere. After I import this class, it works, but I confuse.
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Duc, I would like to see how exactly are you using the class in another class
@kranthikoura411
@kranthikoura411 5 жыл бұрын
Hi Ragav, As you told I have used name locator and executed . I am getting below error. Exception in thread "main" org.openqa.selenium.ElementNotInteractableException: element not interactable I did not get any solution to this issue . Please guide
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Kranthi, pls use waits. I have a session on that. You can also add some wait time before this step
@bennysusanto5524
@bennysusanto5524 5 жыл бұрын
Do you have the example Maven project which we can download ?
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Benny. Check here - github.com/Raghav-Pal/SeleniumJavaFramework1
@sukanyavangari2287
@sukanyavangari2287 4 жыл бұрын
while executing the script chrome browser is showing "Complete your Privacy Checkup" popup window which has "No, thanks" and "Complete" buttons. As per handing alerts should I handle the popup or any other way to resolve this issue?
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi Sukanya, I believe that is one time pop-up. You can try No Thanks and check if that comes up again. If yes than you will have to add a script that handles alert as they appear. Can get some help from here - www.vinsguru.com/selenium-webdriver-how-to-handle-annoying-random-popup-alerts/
@DucNguyen-xn5bd
@DucNguyen-xn5bd 5 жыл бұрын
Hi Raghav, Selenium cannot recognize the search button by name btnk but it work when I change to xpath //div[@class='VlcLAe']//input[@name='btnK']. What's the problem here bro? I got the same issues in many case, they just work when I use Xpath.
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Duc, just see you do not get more than 1 element for the locator (xpath) you are using. Also check this video - kzbin.info/www/bejne/jWrComqqj9ShaK8
@darshanmm9
@darshanmm9 5 жыл бұрын
Hi Raghav, I am getting this error : Selenium - Element is not reachable by keyboard I follow same code as you wrote in your video for google search page. please let me know if I am missing anything in there.
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Darshan, this can be an issue of an overlay. Pls check this stackoverflow.com/questions/49864965/org-openqa-selenium-elementnotinteractableexception-element-is-not-reachable-by
@deepakMCA2009knit
@deepakMCA2009knit 5 жыл бұрын
​@@RaghavPal For google search page when I entered search key it shown a list with 3 options. This is (probably) causing Search button hidden. I am getting same error. Now what I did is : Actions action = new Actions(driver); action.sendKeys(Keys.ENTER).build().perform();
@amitsmart4u
@amitsmart4u 5 жыл бұрын
Hello Raghav, When I was trying the exact same code, I was only able to write into the text box and it was not hitting enter. After little debugging I realized, we were trying to hit enter using search button (named "btnK"), not sure why, because we want to hit enter on the search box itself and not on the search button. So I replaced button_search with textbox_search in the second functional also and then it worked for me. Could you please explain why did you use search button instead of box for hitting and how did it work for you? I did not even need the search button, I completely commented it out and used the single locator for entring text and hitting enter. Appreciate if you could clarify what is working in your case and not working for me. Thank you
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Amit, it's like entering your text in search button and hitting enter. When you enter text in the search box, due to auto-suggestion drop down the search button gets overlapped with drop-down results. Here you have 2 ways. 1. Instead of clicking on search button just hit keyboard ENTER 2. Press keyboard ESC key to collapse the drop down and then click the search button
@amitsmart4u
@amitsmart4u 5 жыл бұрын
@@RaghavPal Hi Raghav, First of all, thank you very much for the response. I did get this point with the earlier video too, but when I tried this (enter command) with button_search it did not work. Then I tried the enter command on textbox_search and it worked. To be precise please see below 2 bullets 1) This code did not work public void setTextIntoSearchBox(String text){ driver.findElement(button_search).sendKeys(text); } public void clickSearchButton(){ driver.findElement(textbox_search).sendKeys(Keys.RETURN); } 2) This one worked public void setTextIntoSearchBox(String text){ driver.findElement(textbox_search).sendKeys(text); } public void clickSearchButton(){ driver.findElement(textbox_search).sendKeys(Keys.RETURN); } Could you please advise why the first one did not work and the second one did? Regards, Amit
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Amit, so here driver.findElement(button_search).sendKeys(text); You are trying to enter something on a button which is not allowed
@amitsmart4u
@amitsmart4u 5 жыл бұрын
@@RaghavPal Hi Raghav, There was a typo in the earlier comment, apologies. The piece of code which did not work is below: public void setTextIntoSearchBox(String text){ driver.findElement(textbox_search).sendKeys(text); } public void clickSearchButton(){ driver.findElement(button_search).sendKeys(Keys.RETURN); Appreciate of you could take a look and advise. Thank you!!
@sumitgarg9181
@sumitgarg9181 3 жыл бұрын
Hello Sir, I am using the POM flow. I need to replace the FirefoxDriver driver = new FirefoxDriver(profile); this value to something like this Browser_Test.driver(opt); Actually, I am trying to download the file and my code is :- FirefoxProfile profile = new FirefoxProfile(); //Set Location to store files after downloading. profile.setPreference("browser.download.dir", "D:\\Sumit Garg C Drive\\eclipse-workspace\\SeleniumMavenEzaccess\\downloadfile"); profile.setPreference("browser.download.folderList", 2); //Set Preference to not show file download confirmation dialogue using MIME types Of different file extension types. profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;"); profile.setPreference( "browser.download.manager.showWhenStarting", false ); profile.setPreference( "pdfjs.disabled", true ); FirefoxOptions opt = new FirefoxOptions(); opt.setProfile(profile); Browser_Test.driver(opt); //Browser_Test.driver.get("ezaccess-rel-react.eba-ckm8i7ie.us-east-2.elasticbeanstalk.com:3000/cross-tab"); Thread.sleep(4000); Browser_Test.driver.findElement(By.cssSelector("div.ez-nav-user:nth-child(3) > img:nth-child(1)")).click(); Thread.sleep(4000); Browser_Test.driver.findElement(By.cssSelector(".ez-dropdown-content > ul:nth-child(1) > li:nth-child(1) > button:nth-child(1)")).click(); Thread.sleep(10000); System.out.println("PDF Downloaded"); So can you please suggest to me what kind of code I can use here to replace the FirefoxOptions opt = new FirefoxOptions();
@RaghavPal
@RaghavPal 3 жыл бұрын
will need to check on this
@philb4462
@philb4462 Жыл бұрын
If anybody can explain to me why driver had to be static I would be grateful. I have never understood when and why the keyword static is used.
@RaghavPal
@RaghavPal Жыл бұрын
ok will plan a session
@muhammadshahriyarabid6592
@muhammadshahriyarabid6592 4 жыл бұрын
Hi Raghav sir, Can I get this code?
@RaghavPal
@RaghavPal 4 жыл бұрын
Hi, you can check this github.com/Raghav-Pal/SeleniumJavaFramework1
@9745754904
@9745754904 5 жыл бұрын
Hi Raghav,,i.have onr scenario.I have to create a user by enterring name,mob no and email and these details are saved in another page(user_listing page)-How can i verify that the entered detail are same on user_listing page
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Jino, you will have to extract and save the values in some variables and then compare the values.
@9745754904
@9745754904 5 жыл бұрын
@@RaghavPal but i need to.use hardcoded data for that.Right?
@RaghavPal
@RaghavPal 5 жыл бұрын
You can use hard-coded or from any data file like excel. This is what you do for example you are entering a username, store this in a variable called uName1. Then when you goto the verification screen fetch the text value of the username field and store it in a variable called uName2. Now compare uName1 = uName2 and based of the result you can log the message
@9745754904
@9745754904 5 жыл бұрын
Thanks.Raghav ,i.understood but is it good to Use hardcoded.data.,since thses datas can change ,if i use a username jino in excel ,next.day if i change it from.excel.,then i need to.chnge from my script
@RaghavPal
@RaghavPal 5 жыл бұрын
No, why do you need to change in your script, It should get whatever value is in excel and store the same. There is a video on how to read and get data from excel files in this playlist.
@MIKEYSREVIEWS
@MIKEYSREVIEWS 5 жыл бұрын
How can TestNG be added to the script?
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi J L, there are videos in the same playlist. Here is the link kzbin.info/aero/PLhW3qG5bs-L8oRay6qeS70vJYZ3SBQnFa
@vinaymishra8533
@vinaymishra8533 2 жыл бұрын
how to get the Notes for your video
@RaghavPal
@RaghavPal 2 жыл бұрын
It's in the Description under the video
@rayfer9930
@rayfer9930 5 жыл бұрын
This video is not playing correctly.
@RaghavPal
@RaghavPal 5 жыл бұрын
Hi Ray, pls check network and try again
@Deniz-ss1sv
@Deniz-ss1sv 3 жыл бұрын
:)
@scaratlas3347
@scaratlas3347 2 жыл бұрын
The google searchbar doesn't have the id thing anymore. Instead of by.id() I used by.name("q"); and it worked fine for me
@RaghavPal
@RaghavPal 2 жыл бұрын
Great, thanks for sharing
@killmesk8
@killmesk8 5 жыл бұрын
if you put "WebDriver driver; " its gonna work the test anyways?? what is the diference with the null? idk, thanks
@RaghavPal
@RaghavPal 5 жыл бұрын
Yes Florencia, using null will just same some memory. You can think of it as a good programming practice
Don't look down on anyone#devil  #lilith  #funny  #shorts
00:12
Devil Lilith
Рет қаралды 13 МЛН
Миллионер | 1 - серия
34:31
Million Show
Рет қаралды 2,3 МЛН
Selenium Framework for Beginners 5 |  How to find Web Elements Locators in Selenium
17:31
Selenium Cucumber BDD Framework with Java and TestNG - Page Object Model | POM
24:59
SDET Adda For QA Automation
Рет қаралды 9 М.
Complete Page Object Model (POM) using Page Factory in Selenium
31:04
Mukesh otwani
Рет қаралды 275 М.
Page Object Model in Selenium Webdriver Step by Step Guide
31:21
Mukesh otwani
Рет қаралды 467 М.