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
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.
Your videos are the best materials I could search in RUclips 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.
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.
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
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
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
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 ?
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!
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.
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?
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
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
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.
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?
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
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
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
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 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
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.
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; }
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.
@@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.
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?
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/
@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?
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 - ruclips.net/video/-0F-YBAQdGE/видео.html You can get Complete Playlist - automationstepbystep.com/ui-testing/
@@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.
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?
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?
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.
Hi Duc, just see you do not get more than 1 element for the locator (xpath) you are using. Also check this video - ruclips.net/video/W9_q7tZon2M/видео.html
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
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
@@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 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!!
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.
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.
@@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
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.
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
@@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();
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
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
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
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.
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
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. -
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;");
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();
Hi Raghav, I never understood POM until now. Thank you so much for so easy tutorial.
so happy to know this Anukriti
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
Thanks for sharing Frank
@@RaghavPal Thank you man
Thanks to you and Raghav.
You are my savior! God Bless you
Thanks a lot Uma
Thank you very much for the video, In just 30 minutes explained this topic very smoothly and easily.
You are welcome Atul
thanks a lot .. following from tunisia 🇹🇳 🇹🇳
Most welcome
Your explanations methods are ..... no words man
Thanks for watching Subhash
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...
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
I will check this and plan. thanks for the feedback Sairamaraju
Thanks for this. I find your videos very helpful and easy to understand.
Most welcome Niraj
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.
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
Thank you so much for making these videos. I learnt a great deal from your playlist on Selenium!
You're very welcome!
Very helpful videos, thank you! It might help a few people if you were to add comments as you went through these.
Glad it was helpful!
You are truly awesome the way you explained topic is splendid. Could you please make one selenium project using Intellij.
Loved your explanation method raghav sir . Thanks for helping us out.
You're welcome Anand
Your videos are the best materials I could search in RUclips 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.
Feedback taken Vova. I will check on that
Thank you it is perfect n helpful
Most welcome Subhadeep
awesome and simple explanation
Glad it was helpful!
very useful thank you Raghav
Always welcome
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.
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
@@RaghavPal
Thanks alot Raghav.
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
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
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
Hi, you will find it in the same playlist. In TestNG videos I have used the POM approach
Thank you very mutch
You are welcome
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 ?
Hi Aloha, you can create a base class and make it abstract and then make this class as base class for all test classes.
@@RaghavPal Thank you :)
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!
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.
Thankyou so much Raghav for your reply.. Your tutorials are simply superb ! Keep up the great work.
Really thanks ..............
Most welcome Sairam
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?
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
@@RaghavPal Thanks Raghav
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
Yes you can do that
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.
Hi, you can check all videos here - automationstepbystep.com/online-courses/
If there is a logout button or navigate link, it is common in all the pages. On which page we locate this web Element?
Hi Kshipra, in that case you can keep the logout object in home page
@@RaghavPal Hi Raghav!! Is there any specific reason for keeping it in Home page? Then, how it can be accessed on other pages?
Basically we just try to keep it in a way that others can find it easily
Thank you greatly!
You're welcome Rose
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?
Hi Eamon, thanks for the message. You can check other videos here - automationstepbystep.com/ui-testing/
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
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
@@RaghavPal Thanks a lot.
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
Hi Kranthi, pls use waits. I have a session on that. You can also add some wait time before this step
Thank you :)
You're welcome Zheng
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
Hi Samarth, you can use data driven testing and can also check TestNg dataprovider, there is a video on that
@@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
I will need to check on this in detail
Hi Raghav,
Can you please make a video on it
TIA
@@RaghavPal
Hi Raghav,
Any updates?
Kudos to Raghav
Thanks
Hi, how to return multiple variables values from the same method without creating a different method for each field.
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.
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;
}
Hi Raghav , any downside of adding action methods only the test case and not in the page class ?
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.
@@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.
Yes, go as per your needs
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?
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/
@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?
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 - ruclips.net/video/-0F-YBAQdGE/видео.html
You can get Complete Playlist - automationstepbystep.com/ui-testing/
@@RaghavPal
I like this method because the locators are well organized at the top of the class.
@@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.
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?
Hi can check testng videos in playlist automationstepbystep.com/online-courses/
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?
Yes, you can do
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.
Hi Duc, just see you do not get more than 1 element for the locator (xpath) you are using. Also check this video - ruclips.net/video/W9_q7tZon2M/видео.html
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
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
@@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
Hi Amit, so here
driver.findElement(button_search).sendKeys(text);
You are trying to enter something on a button which is not allowed
@@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!!
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.
Hi Duc, I would like to see how exactly are you using the class in another class
If there are 1000 pages,do we need to create 1000 page classss and corresponding 1000 test classes,
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.
@@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
Yes, you can do the categorizations as per your need and as per the best practices
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.
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.
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
@@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();
Do you have the example Maven project which we can download ?
Hi Benny. Check here - github.com/Raghav-Pal/SeleniumJavaFramework1
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
Hi Jino, you will have to extract and save the values in some variables and then compare the values.
@@RaghavPal but i need to.use hardcoded data for that.Right?
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
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
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.
hello sir how can we handle windows or tabs in a framework i have tried to find out but failed please help me.
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
I am getting error Error message displayed when opening Eclipse: "An error has occurred" Can you reply tome please
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.
-
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();
will need to check on this
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.
ok will plan a session
Hi Raghav sir, Can I get this code?
Hi, you can check this github.com/Raghav-Pal/SeleniumJavaFramework1
How can TestNG be added to the script?
Hi J L, there are videos in the same playlist. Here is the link ruclips.net/p/PLhW3qG5bs-L8oRay6qeS70vJYZ3SBQnFa
how to get the Notes for your video
It's in the Description under the video
:)
This video is not playing correctly.
Hi Ray, pls check network and try again
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
Great, thanks for sharing