Page Object Model (Page Navigation) in Selenium — Part 2
In this post we will discuss about Page Object Model Page Navigations in Selenium
Please leave your comments !!!
Thanks,
Karthik KK
Post Author:
Karthik kk
19 Replies to “Page Object Model (Page Navigation) in Selenium — Part 2”
Part 4,5 and 6 videos are really useful, checked in youtube already, just curious to know if you have videos placed after part 6 to understand the rest of POM, thanks!
I have a query related to video 6 in which we are returning a web page i.e. Selenium page.
I am getting the below error message while I am executing the same code as in your video.
Error : Exception in thread “main” java.lang.NullPointerException
Not sure where the exception is happening, if you let us know the exact LOC of error, may be I can figure out. Since this code is working fine for years without any problem.
I am not able to add static class as its showing error.Could you please let me know where the class needs to be added in order to resolve null pointer exception error.
Did the NullPointException ever get resolved? I am seeing it at the ClickDownload()
Exception in thread “main” java.lang.NullPointerException
at org.openqa.selenium.support.pagefactory.DefaultElementLocator.findElement(DefaultElementLocator.java:69)
at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:38)
at com.sun.proxy.$Proxy4.click(Unknown Source)
at org.POM.SeleniumPageObjects.ClickDownload(SeleniumPageObjects.java:28)
at org.POM.GoogleSearchTest.main(GoogleSearchTest.java:34)
I wanted to know is there a way to implement Explicit wait or Fluent wait in POM concept?
public class GoogleSearchText {
public static WebDriver driver;
public static void main(String[] args) throws InterruptedException {
System.setProperty(“webdriver.chrome.driver”, “D:\\Training\\Installation stuff\\Exe Files\\chromedriver.exe”);
driver = new ChromeDriver();
driver.get(“https://www.google.com/”);
GoogleHomePageObjects page = new GoogleHomePageObjects(driver);
page.SearchGoogle(“SeleniumHQ”);
page.ClickSelenium();
SeleniumHomePageObject Sel = new SeleniumHomePageObject(driver);
//Can v Add Explicit or Fluent wait for the below task, if yes how?
Sel.ClickDownload();
Sel.ClickHome();
}
}
Part 4,5 and 6 videos are really useful, checked in youtube already, just curious to know if you have videos placed after part 6 to understand the rest of POM, thanks!
Awesome videos and stuffs by u!!
really u know how to teach!!
Glad you like it Sanjiv !!!
Hi Karthik,
Video uploaded in part 6 is same as part 5 and is repeated in this video series. Could you please sort this?
Regards,
Sundeep.
Nope both are different.
Could you please recheck again, as I am seeing the same videos on both of them.
Regards,
Sundeep.
I am getting the following error when running the code:
org.openqa.selenium.ElementNotVisibleException
My code is as follows:package excuteautomation.pom;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
public class GoogleHomePageObjects {
// initialise anyobject in the page
public GoogleHomePageObjects(WebDriver driver) {
PageFactory.initElements(driver, this);
}
@FindBy(id=”gs_htif0″)
public WebElement txtSearch;
@FindBy(name=”btnG”)
public WebElement btnSearch;
}
package excuteautomation.pom;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class GoogleSearchTest {
public static WebDriver driver = new FirefoxDriver();
public static void main(String[] args) {
driver.get(“https://www.google.co.uk”);
driver.manage().window().maximize();
//object for the page
GoogleHomePageObjects page = new GoogleHomePageObjects(driver);
// search for the text selenium
page.btnSearch.sendKeys(“selenium”);
// click the search button
page.btnSearch.click();
}
}
Hi Karthik,
I have a query related to video 6 in which we are returning a web page i.e. Selenium page.
I am getting the below error message while I am executing the same code as in your video.
Error : Exception in thread “main” java.lang.NullPointerException
Can you please follow this step to fix the issue.
http://stackoverflow.com/questions/34145422/selenium-framework-page-object-model-and-page-navigation/34147044#34147044
Thanks,
Karthik KK
I have follow the Steps for static class but Error not get resolve
Exception in thread “main” java.lang.NullPointerException
Hi Karthik,
i tried that method but still could not resolve the issue.Could you please explain how to resolve the null pointer exception issue?
Thanks,
Not sure where the exception is happening, if you let us know the exact LOC of error, may be I can figure out. Since this code is working fine for years without any problem.
Thanks,
Karthik KK
In Video 7 when you executed the code, it seems that you have got the same error.
Exception in thread “main” java.lang.NullPointerException
org.pom.SeleniumPageObjects.ClickDownload(SeleniumPageObjects.java : 25)
org.pom.GoogleSearchTest.main(GoogleSearchTest.java : 32)
Please help me out to resolve the error
Hi, thanks for this useful post.
Both part 4 and 5 videos in this series are the same..
Hi Karthik,
Your videos are of great help, but here both parts represent the same content. Can you pls check these two videos.
Thanks.
Hi Karthik,
Here is the link for 6th video which is good in you tube.https://www.youtube.com/watch?v=IUBwtLG9hbs&index=6&list=PL6tu16kXT9Prgk2f37ozqcdZac9pSATf6, but in website 5th and 6th part are same.
Thanks
I am not able to add static class as its showing error.Could you please let me know where the class needs to be added in order to resolve null pointer exception error.
Did the NullPointException ever get resolved? I am seeing it at the ClickDownload()
Exception in thread “main” java.lang.NullPointerException
at org.openqa.selenium.support.pagefactory.DefaultElementLocator.findElement(DefaultElementLocator.java:69)
at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:38)
at com.sun.proxy.$Proxy4.click(Unknown Source)
at org.POM.SeleniumPageObjects.ClickDownload(SeleniumPageObjects.java:28)
at org.POM.GoogleSearchTest.main(GoogleSearchTest.java:34)
Hi,
Thanks for the wonderful clarity on POM concept!
I wanted to know is there a way to implement Explicit wait or Fluent wait in POM concept?
public class GoogleSearchText {
public static WebDriver driver;
public static void main(String[] args) throws InterruptedException {
System.setProperty(“webdriver.chrome.driver”, “D:\\Training\\Installation stuff\\Exe Files\\chromedriver.exe”);
driver = new ChromeDriver();
driver.get(“https://www.google.com/”);
GoogleHomePageObjects page = new GoogleHomePageObjects(driver);
page.SearchGoogle(“SeleniumHQ”);
page.ClickSelenium();
SeleniumHomePageObject Sel = new SeleniumHomePageObject(driver);
//Can v Add Explicit or Fluent wait for the below task, if yes how?
Sel.ClickDownload();
Sel.ClickHome();
}
}