Base URL is the URL which is provided in Selenium Automation while creating an object for Selenium Class.
Selenium object1 = new DefaultSelenium("localhost", 4444, "*firefox", "Base URL");
Suppose if we have given the home page of the application as a Base URL as shown below:
Selenium object1 = new DefaultSelenium("localhost", 4444, "*firefox", "http://book.theautomatedtester.co.uk");
And if we want to navigate to the 'chapter1' page of the Base URL, its not required to write the complete URL in the open( ) method, instead we can just write the '/chapter' part of the URL as shown below:
object1.open("http://book.theautomatedtester.co.uk/chapter1") //This will take the User to the chapter1 page
object1.open("/chapter1"); //This will append this '/chapter1' part of the URL with the provided base URL and will take the User to the chapter1 page.
So the above two statements will work same (i.e they both take the User to the chapter1 page only).
Lets Implement This:
Pre-requisites:
1. Create a new Project say 'RC-Project9' in Eclipse IDE
2. Configure the Project to work with Selenium RC
3. Configure the Selenium Standalone Server to run from Eclipse IDE
4. Start the Selenium Standalone Server
5. Create a package say 'package_nine' under the newly created project.
6. Create a Java Class file say 'Class9' under the newly created package as shown below:
Actual Steps:
1. Write the following code into the newly created Java Class file as shown below and make sure that you resolve all the errors before going to next step:
2. Start the Selenium Standalone Server
3. Save and Run the 'Class9.java' file by selecting the 'JUnit Test' option and ensure that 'Home' page of the provided Base URL is displayed followed by 'chapter1' page of the Base URL as shown below:
Watch the below video:
Click here to watch the video.
Download this Project:
Click here to download this project and import into Eclipse IDE on your machine.
Please comment below to feedback or ask questions.
Using isTextPresent( ) method will be explained in the next post.
No comments:
Post a Comment