Difference between
Absolute path & Relative path.
Absolute path will start
with root path (/) and Relative path will from current path (//)
Click Here for Detailed
Answer
Absolute xPath
: /html/body/div[3]/div[2]/div[2]/div[2]/div[2]/div[2]/div[2]/div/div[4]/div[1]/div/div[@id='main']/div[@id='Blog1']/div[1]/div[1]/div/div[1]/div/h3/a
Relative xPath : //h3/a[text()='Working on New Window']
Relative xPath : //h3/a[text()='Working on New Window']
Or In Selenium IDE.
http://ruchi-myseleniumblog.blogspot.in
and
http://ruchi-myseleniumblog.blogspot.in/2013/12/100-selenium-interview-questions.html
Both are absolute path.
Let say you have set you base URL as http://ruchi-myseleniumblog.blogspot.in
and you want to go to other page of it like
http://ruchi-myseleniumblog.blogspot.in/2013/12/100-selenium-interview-questions.html
or
http://ruchi-myseleniumblog.blogspot.in/2013/12/basic-core-java-interview-questions.html
then you don’t have to type complete absolute path each time. use relative path like
/2013/12/100-selenium-interview-questions.html.
http://ruchi-myseleniumblog.blogspot.in
and
http://ruchi-myseleniumblog.blogspot.in/2013/12/100-selenium-interview-questions.html
Both are absolute path.
Let say you have set you base URL as http://ruchi-myseleniumblog.blogspot.in
and you want to go to other page of it like
http://ruchi-myseleniumblog.blogspot.in/2013/12/100-selenium-interview-questions.html
or
http://ruchi-myseleniumblog.blogspot.in/2013/12/basic-core-java-interview-questions.html
then you don’t have to type complete absolute path each time. use relative path like
/2013/12/100-selenium-interview-questions.html.
Or
/2013/12/basic-core-java-interview-questions.html
Once you set the base URL
you don’t have to pass the same URL for any of the page on that webpage.
First set the base URL in SIDE ashttp://ruchi-myseleniumblog.blogspot.in then run script.
First set the base URL in SIDE ashttp://ruchi-myseleniumblog.blogspot.in then run script.
Nice explanation Ruchi... Great job
ReplyDeletenice explanation
ReplyDeleteI am using intern testing tool with an application developed in dojo 1.8 (using custom template widgets). The page loads successfully in the webdriver but intern is not able to identify the HTML elements and throws timeout error. waitForElementByCssSelector, waitForVisibleById or elementById give timeout error.
ReplyDeleteplease help
I am using intern testing tool with an application developed in dojo 1.8 (using custom template widgets). The page loads successfully in the webdriver but intern is not able to identify the HTML elements and throws timeout error. waitForElementByCssSelector, waitForVisibleById or elementById give timeout error.
ReplyDeleteNice
ReplyDeleteHI Ruchi, Hope you doing good,
ReplyDeleteIf possible can you please post in detail about the Xpath.
This comment has been removed by the author.
ReplyDeleteThanks.Nice Explanation
ReplyDeletenice blog....Thanks :)
ReplyDelete@Sapna
ReplyDeleteuse WebDriverWait to resolve this issue.
package Package;
ReplyDeleteimport java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.*;
public class Openbrowser {
@Test
public void method() throws Exception
{
WebDriver driver=new FirefoxDriver();
String relpath="https://www.google.co.in/";
String abspath="/imghp?hl=en&tab=wi&ei=omUhVPCQJ8PjuQSUvICgBw&ved=0CAQQqi4oAg";
driver.get(relpath);
driver.get(abspath);
driver.manage().timeouts().implicitlyWait(400, TimeUnit.SECONDS);
//driver.close();
System.out.println("Test");
//driver.quit();
}
}
I have tried but i could not be able to navigate to relative path.Please suggest....
Nice job... Thanks
ReplyDelete@nagarjunakrishna illuri:
ReplyDeleteYou have confused yourself a bit. You took the seedURL as relpath and the relativePath as abspath. Also, you are unable to get to your relpath because you immediately initialized your driver to abspath, which according to your string initialization, cannot exist on its own. You need to do the following:
String absolutePath = relpath + abspath;
driver.get(absolutePath);
Nice blog thanks
ReplyDeleteCan you send me framework link my maild jessica102214@gmail.com
Hello, I would like to subscribe for this webpage to get newest updates,
ReplyDeleteso where can i do it please help.