Earn Money in 10 days

Selenium Videos

Protractor In Selenium

Livechat

Friday, 7 November 2014

How to open Browser

How to open a browser??
1.WebDriver driver = new Firefox Driver();
driver.get("http://gmail.com");  
                 or                  
2.WebDriver driver = new FirefoxDriver();
driver.navigate().to("http://gmail.com");

Difference between driver.get("http://gmail.com") and driver.navigate().to("http://gmail.com");

1.driver.get();WebDriver will wait until the page has fully loaded (that is, the onload event has fired) before returning control to your test or script. It’s worth noting that if your page uses a lot of AJAX on load then WebDriver may not know when it has completely loaded. If you need to ensure such pages are fully loaded then you can use waits.
2.driver.navigate to:
History and Location 
Earlier, we covered navigating to a page using the get command (driver.get("http://www.example.com")) As you’ve seen, WebDriver has a number of smaller, task-focused interfaces, and navigation is a useful task. Because loading a page is such a fundamental requirement, the method to do this lives on the main WebDriver interface, but it’s simply a synonym to:driver.navigate().to("http://gmail.com");To reiterate: navigate().to() and get() do exactly the same thing.
The navigate interface also exposes the ability to move backwards and forwards in your browser’s history:driver.navigate().forward(); driver.navigate().back();

4 comments:

  1. Hi guys ,I want to read complete data from excel file i tried writing the code but i am getting this following error.I have around 100 records & i want fetch all the data


    Exception in thread "main" java.lang.UnsupportedOperationException: Not supported yet.
    at javaapplication1.ExcelLibrary.getRowCnt(ExcelLibrary.java:20)
    at javaapplication1.JavaApplication1.main(JavaApplication1.java:30)
    Java Result: 1

    So please help me out thank u guys

    ReplyDelete
    Replies
    1. Hi Rohini,

      If you are using Apache POI then you can call method called getLastRowNum that will return u number of rows in excel.

      You can run a for loop after that and perform the action based on your requirement.

      Delete
    2. K tthank u...but if i include a Excel library den its showing a exception as below
      Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: javaapplication1.ExcelLibrary
      at javaapplication1.JavaApplication1.main(JavaApplication1.java:30)
      Java Result: 1.............so plz help me out

      Delete
  2. K tthank u...but if i include a Excel library den its showing a exception as below
    Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: javaapplication1.ExcelLibrary
    at javaapplication1.JavaApplication1.main(JavaApplication1.java:30)
    Java Result: 1.............so plz help me out

    ReplyDelete

Popular Posts

 
subscribe
Subscribe Us
emailSubscribe to our mailing list to get the updates to your email inbox... We can't wait more to have your email in our subscribers email list. Just put your nice email in below box: