Site Loader
Auckland, New Zealand

Post Author: Karthik kk

19 Replies to “Page Object Model (Page Navigation) in Selenium — Part 2”

  1. 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!

  2. 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.

  3. 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();

    }

    }

  4. 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

      1. I have follow the Steps for static class but Error not get resolve
        Exception in thread “main” java.lang.NullPointerException

      2. 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,

        1. 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

  5. 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

  6. Hi Karthik,

    Your videos are of great help, but here both parts represent the same content. Can you pls check these two videos.

    Thanks.

  7. 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.

  8. 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)

  9. 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();
    }
    }

Leave a Reply

Your email address will not be published. Required fields are marked *