Table of content

Open Webpage

We can open the browser by using get(“᾿) a non static method present in the FirefoxDriver class, it accepts a string as arguments and the string should be the website address.

A special thing about this get(“᾿) method is it will not give control to the next line till the page loads completely.


						import org.openqa.selenium.WebDriver;
						import org.openqa.selenium.firefox.FirefoxDriver;

						public class OpenWebSite 
						{
							public static void main(String[] args) throws Exception 
							{
								WebDriver driver=new FirefoxDriver();
								
								// tries to open chercher.tech page
								driver.get("chercher.tech");			
							}
						}

					

Not Able to Open Website

Did you able to open the google. if answer is nope means why ?

Did you get following error ?
Exception in thread "main" org.openqa.selenium.WebDriverException: f.QueryInterface is not a function Command duration or timeout: 94 milliseconds

Solution:
Whenever we pass the website address to the get() method .it first of checks for the protocol in the address ,but in the above program we didnot mention any the protocol.

What is protocol ?
Protocol is simple it mention what kind of site is that.
Eg for protocol:
-http
-https
-ftp
-file

Let's edit the above program

Code Example for Open a Webpage


						import org.openqa.selenium.WebDriver;
						import org.openqa.selenium.firefox.FirefoxDriver;

						public class OpenSite 
						{
							public static void main(String[] args) throws Exception 
							{
								WebDriver driver=new FirefoxDriver();
								
								// tries to open https://chercher.tech page
								driver.get("https://chercher.tech"); 
										
							}

						}
					

Hybrid Inheritance in Java and Selenium

Work Offline

Let us take below scenario.
I do not have an Internet connection but I saved some WebPages in my computer, is it possible for me to work in selenium ?

Answer is YES you can like below.

Open the saved webpage in a browser and copy the address in the address bar, this will have protocol as “file᾿ it looks something like below
file:///C:/Users/path/selenium.html


						import org.openqa.selenium.WebDriver;
						import org.openqa.selenium.firefox.FirefoxDriver;

						public class OpenSite 
						{
							public static void main(String[] args) throws Exception 
							{
								WebDriver driver=new FirefoxDriver();
								// opens the file like real page
								driver.get("file:///C:/Users/path/selenium.html");
							}
						}

					

Note: If the site doesnot have the the protocol then just copy paste the url into eclipse it will automatically imports the protocol.

About Author

Myself KarthiQ, I am the author of this blog, I know ways to write a good article but some how I donot have the skills to make it to reach people, would you like help me to reach more people By sharing this Article in the social media.

Share this Article Facebook
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions
  • sandeep
    Sprint Section : Spelling mistake of testcase preparation : estcase preparation
    Reply
    • karthiQ [ admin]
      Thanks, Sandeep,. We will correct it
      Reply
  • Nishant
    1. Kindly provide next and previous link to move one page to another page.
    2. Kindly provide a link at the bottom of the each page by clicking link I can go to the top without scrolling.
    Above both scenarios will make site more user friendly. Other than this I liked your website most.
    
    Reply
    • karthiQ [ admin]
      Hi Nishanth,
      
      We have incorporated the second point, but for first point it will take little more time.
      Reply
  • Recent Addition

    new tutorial Registrations for Selenium Online Training is Over.

    Below are the training details:
    Meeting link : https://zoom.us/j/737840591
    Starting Time : 9:00PM 18th DEC 2018
     
    Join My Facebook Group
    Join Group