Need Xpath for this

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Need Xpath for this

tulsi.tester
Hi All,

Please let me know how to find the xpath for the attached image.XpathRequired.jpg
Reply | Threaded
Open this post in threaded view
|

Re: Need Xpath for this

softwaretestingforum
Administrator
I noticed that image is inside iframe, hence first you need to switch to iframe and then use following xpath on image

"//input[name='UserName']"
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Need Xpath for this

tulsi.tester
Hi tarun,

I am able to find the xpath till the iframe, but beyond that i couldn't proceed to find the form tag and then. any possible solution to reach to form tag would help me.
Reply | Threaded
Open this post in threaded view
|

Re: Need Xpath for this

softwaretestingforum
Administrator
Are you using selenium1 or 2?
Do you encounter any specific exception?
once you switch to frame then you can use the xpath for image what I mentioned in previous thread.
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Need Xpath for this

tulsi.tester
Hi Tarun,

I am using selenium 1.0.

This is the xpath given by me till the iframe

//div[@id='SLB-Contenedor']//div[@id='SLB-Contenido']//iframe[@id='if_1329466456152-Image'].

but when i am trying to extend the xpath with your mentioned xpath it is showing as Invalid xpath.


The scenario is when i clicked on sign in button of a page, a pop up like window(but not real pop up bcz i doesn't has any ID or name) comes. There i need to enter the credentials. Before focusing my cursor position to the text fields i need to focus the opened pop up like window right. I am unable to do that.
Reply | Threaded
Open this post in threaded view
|

Re: Need Xpath for this

softwaretestingforum
Administrator
I repeat - Did you select frame using method ???

http://selenium.googlecode.com/svn/trunk/docs/api/java/com/thoughtworks/selenium/DefaultSelenium.html#selectFrame(java.lang.String)

only after this you can bring control on image.
Also your frame looks dynamic hence you should rather use -

//iframe[contains(@id,'Image')]
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Need Xpath for this

tulsi.tester
Hi Tarun,

I have given the xpath mentioned by you. But it is unable to find it. see below code


String signIn = "//div[@id='accessBox']/table/tbody/tr/td[@id='buttons']/a/img";
String frame = "//div[@id='SLB-Contenedor']//div[@id='SLB-Contenido'//iframe[contains(@id,'Image')]";
String uname = "//*[@id='UserName']";
String pwd = "//*[@id='Password']";
String Pop_SignIn = "//*[@id='logonDiv']/table[2]/tbody/tr/td[2]/input";
String logout = "//*[@id='buttons']/a[2]/img";
       
       
        selenium.click(signIn);
        Reporter.log("Clicked on SignIn button");
        selenium.selectFrame(frame);
        selenium.setCursorPosition(uname,"0");
        selenium.type(uname, "XXXXXXX");
        selenium.setCursorPosition(pwd,"0");
        selenium.type(pwd,"YYYYYYY");
        selenium.click(Pop_SignIn);
        selenium.waitForPageToLoad("30000");
        selenium.selectWindow(null);
        selenium.click(logout);
        selenium.waitForPageToLoad("30000");  
Reply | Threaded
Open this post in threaded view
|

Re: Need Xpath for this

softwaretestingforum
Administrator
What's the exception you encounter?
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Need Xpath for this

tulsi.tester
When I am using selectFrame() method it throws an Exception: it is not a frame. When I am using selectWindow(id), it  fails due to time out exception.
Reply | Threaded
Open this post in threaded view
|

Re: Need Xpath for this

softwaretestingforum
Administrator
Can you use Firebug or Selenium IDE to check if it highlights your frame element xpath -

//div[@id='SLB-Contenedor']//div[@id='SLB-Contenido'//iframe[contains(@id,'Image')]

Also from you image of xPath it looks sort of disabled.  Are you sure frame is available when you try to select it?
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Need Xpath for this

tulsi.tester
when i used the xpath given by you, it is not highlighting any any element in IDE or not showing any element in Xpath Checker.
Reply | Threaded
Open this post in threaded view
|

Re: Need Xpath for this

softwaretestingforum
Administrator
It means you need first find the right xpath/css locator.
Analyze you html again and see how iframe appears in it.
~ seleniumtests.com