How to get the element path like href
Page 1 of 1 • Share •
How to get the element path like href
hi, i want to get the button's href value,
this should return a href like "http://sitename/dev/auction/auction/view/id/ "
can anyone help me that how can i get the page elements urls.
Regards:
Geek
this should return a href like "http://sitename/dev/auction/auction/view/id/ "
can anyone help me that how can i get the page elements urls.
Regards:
Geek
geek- Posts: 4
Join date: 2009-08-10
Re: How to get the element path like href
Hi,
First of all welcome and thanks to join this forum.
Now the solution for your problem is:
storeAttribute ( attributeLocator, variableName )
Example:
In IDE:
storeAttribute| locatorOfYourButton@href| VariableName [This will store the href or link of that button into the variableName and now you can use this variable as per requirement ]
type| textFieldLocator| ${variableName}
In RC:
I am telling you snippet of code in java.
String variableName = getAttribute(locatorOfYourButton@href); [Similarly use this variable anywhere you want].
Hope this will help you solve your problem. Best Of Luck.
Bye
First of all welcome and thanks to join this forum.
Now the solution for your problem is:
storeAttribute ( attributeLocator, variableName )
Example:
In IDE:
storeAttribute| locatorOfYourButton@href| VariableName [This will store the href or link of that button into the variableName and now you can use this variable as per requirement ]
type| textFieldLocator| ${variableName}
In RC:
I am telling you snippet of code in java.
String variableName = getAttribute(locatorOfYourButton@href); [Similarly use this variable anywhere you want].
Hope this will help you solve your problem. Best Of Luck.
Bye
Re: How to get the element path like href
hi Admin, thanks to immediate reply on my query,
well i have tried this , but my query is little bit more complicated now,
well i have a listing items on the page, and every listing item has its own unique id, which is enclosed in a href link,
please take a look on following code , that will give you more detail understanding of my issue
//////////////////////////// Start //////////////////////////////
<li class="item">
<p class="product-image">
</p>
<h5>
</h5>
<div class="current_bid">
<span class="left">Current Bid:</span>
<button class="form-button" onclick="setLocation('http://www.xyz.com/dev/auction/auction/view/id/753/')">
</button>
<strong>
</strong>
</div>
<div class="bids_number">
</div>
<div class="time_remaining">
</div>
</li>
//////////////// from here again a new listing item container starts to fill the next item detail on the page.
<li class="item">
<p class="product-image">
</p>
<h5>
</h5>
<div class="current_bid">
<span class="left">Current Bid:</span>
<button class="form-button" onclick="setLocation('http://www.xyz.com/dev/auction/auction/view/id/755/')">
</button>
<strong>
</strong>
</div>
<div class="bids_number">
</div>
<div class="time_remaining">
</div>
</li>
//////////////// from here again a new listing item container starts to fill the next item detail on the page.
<li class="item">
<p class="product-image">
</p>
<h5>
</h5>
<div class="current_bid">
<span class="left">Current Bid:</span>
<button class="form-button" onclick="setLocation('http://www.xyz.com/dev/auction/auction/view/id/756/')">
</button>
<strong>
</strong>
</div>
<div class="bids_number">
</div>
<div class="time_remaining">
</div>
</li>
</ol>
//////////////////////////// End //////////////////////////////
like i need to get these bold ids number
and in return it will give me
http://www.xyz.com/dev/auction/auction/view/id/753/
http://www.xyz.com/dev/auction/auction/view/id/755/
http://www.xyz.com/dev/auction/auction/view/id/756/
waiting for your reply
best Regards:
Atif mahmood.
well i have tried this , but my query is little bit more complicated now,
well i have a listing items on the page, and every listing item has its own unique id, which is enclosed in a href link,
please take a look on following code , that will give you more detail understanding of my issue
//////////////////////////// Start //////////////////////////////
<li class="item">
<p class="product-image">
</p>
<h5>
</h5>
<div class="current_bid">
<span class="left">Current Bid:</span>
<button class="form-button" onclick="setLocation('http://www.xyz.com/dev/auction/auction/view/id/753/')">
</button>
<strong>
</strong>
</div>
<div class="bids_number">
</div>
<div class="time_remaining">
</div>
</li>
//////////////// from here again a new listing item container starts to fill the next item detail on the page.
<li class="item">
<p class="product-image">
</p>
<h5>
</h5>
<div class="current_bid">
<span class="left">Current Bid:</span>
<button class="form-button" onclick="setLocation('http://www.xyz.com/dev/auction/auction/view/id/755/')">
</button>
<strong>
</strong>
</div>
<div class="bids_number">
</div>
<div class="time_remaining">
</div>
</li>
//////////////// from here again a new listing item container starts to fill the next item detail on the page.
<li class="item">
<p class="product-image">
</p>
<h5>
</h5>
<div class="current_bid">
<span class="left">Current Bid:</span>
<button class="form-button" onclick="setLocation('http://www.xyz.com/dev/auction/auction/view/id/756/')">
</button>
<strong>
</strong>
</div>
<div class="bids_number">
</div>
<div class="time_remaining">
</div>
</li>
</ol>
//////////////////////////// End //////////////////////////////
like i need to get these bold ids number
and in return it will give me
http://www.xyz.com/dev/auction/auction/view/id/753/
http://www.xyz.com/dev/auction/auction/view/id/755/
http://www.xyz.com/dev/auction/auction/view/id/756/
waiting for your reply
best Regards:
Atif mahmood.
geek- Posts: 4
Join date: 2009-08-10
Re: How to get the element path like href
hi,
It is also work like same , just create a id of that button from selenium ide. You have to find unique name for that and place it like this
storeAttribute | id@onclick| variableName
output: variableName = setLocation('http://www.xyz.com/dev/auction/auction/view/id/756/')
After you have url and you can verify it.
It is also work like same , just create a id of that button from selenium ide. You have to find unique name for that and place it like this
storeAttribute | id@onclick| variableName
output: variableName = setLocation('http://www.xyz.com/dev/auction/auction/view/id/756/')
After you have url and you can verify it.
Re: How to get the element path like href
hi admin,
well i'm not an expert in selenium-rc java . i have just started work on it.
your solution seems like it works but when i try to use this method like
selenium.storeAttribute();
then i'm not able to find that method in my selenium ver.
i'm useing " selenium-remote-control-1.0.1-dist" ver.
would you please tell me what can i do to solve my problem
please reply me as soon as you can , because my project submittion date is very near
thankx
Regards:
geek
well i'm not an expert in selenium-rc java . i have just started work on it.
your solution seems like it works but when i try to use this method like
selenium.storeAttribute();
then i'm not able to find that method in my selenium ver.
i'm useing " selenium-remote-control-1.0.1-dist" ver.
would you please tell me what can i do to solve my problem
please reply me as soon as you can , because my project submittion date is very near
thankx
Regards:
geek
geek- Posts: 4
Join date: 2009-08-10
Re: How to get the element path like href
and one thing more i have the attribute like this
" <button class="form-button" onclick="setLocation('http://www.abc.com/dev/auction/auction/view/id/753/')">"
now i want to store this " http://www.abc.com/dev/auction/auction/view/id/753/" value into a variable.
or
<a title="" href="http://ww.abc.com/dev/auction/auction/view/id/753/"><img height="174" width="174" title="" alt="" src="https://www.abc.com/dev/media/catalog/product/cache/1/small_image/174x174/3594a9c230972d/T/V/TV.jpg"/>
</a>
and i want to this value
" http://ww.abc.com/dev/auction/auction/view/id/753/"
i have tried
selenium.getAttibute("//[@class='form-button']");
selenium.getAttibute("//[@a='title']");
but its of no use
Please take a look on it and tell me how can i get these values.
regards:
GEEK
" <button class="form-button" onclick="setLocation('http://www.abc.com/dev/auction/auction/view/id/753/')">"
now i want to store this " http://www.abc.com/dev/auction/auction/view/id/753/" value into a variable.
or
<a title="" href="http://ww.abc.com/dev/auction/auction/view/id/753/"><img height="174" width="174" title="" alt="" src="https://www.abc.com/dev/media/catalog/product/cache/1/small_image/174x174/3594a9c230972d/T/V/TV.jpg"/>
</a>
and i want to this value
" http://ww.abc.com/dev/auction/auction/view/id/753/"
i have tried
selenium.getAttibute("//[@class='form-button']");
selenium.getAttibute("//[@a='title']");
but its of no use
Please take a look on it and tell me how can i get these values.
regards:
GEEK
geek- Posts: 4
Join date: 2009-08-10
Re: How to get the element path like href
hi,
1. First of all you are using command wrongly. Check the selenium core reference contains all command of selenium. use like this
selenium.storeAttribute(locator @ which value you want);
String variableName =
selenium.storeAttribute(//xyx @ href);
2. Now about second point
String var = selenium.getAttibute("//[@class='form-button']@onclick");
By this command you will get value = setLocation('http://www.abc.com/dev/auction/auction/view/id/753/')remove setLocation from any login in programming language and after that you will have url.
For Second object:
String var2 = selenium.getAttibute("//[@a='title']@href");
after that var2 contain value = href="http://ww.abc.com/dev/auction/auction/view/id/753/
I hope this will help you. Try to do R&d On this you will get through it. best of luck
Bye
1. First of all you are using command wrongly. Check the selenium core reference contains all command of selenium. use like this
selenium.storeAttribute(locator @ which value you want);
String variableName =
selenium.storeAttribute(//xyx @ href);
2. Now about second point
String var = selenium.getAttibute("//[@class='form-button']@onclick");
By this command you will get value = setLocation('http://www.abc.com/dev/auction/auction/view/id/753/')remove setLocation from any login in programming language and after that you will have url.
For Second object:
String var2 = selenium.getAttibute("//[@a='title']@href");
after that var2 contain value = href="http://ww.abc.com/dev/auction/auction/view/id/753/
I hope this will help you. Try to do R&d On this you will get through it. best of luck
Bye
Similar topics» X3-00 on/off path
» How to get the element path like href
» How to identify element using anchor tag text
» How to find the exact element usnig xpath
» Bux Element
» How to get the element path like href
» How to identify element using anchor tag text
» How to find the exact element usnig xpath
» Bux Element
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum

» sample webdriver code for php users
» which standalone server to use
» Dynamic Drop Down Selection
» It is possible to find list of all URL's exist in any web page in selenium ide
» It is possible to compare 2 same images in selenium IDE.
» how to compare 2 ULR's which is exist in same web page (View page source).
» Web Driver: Unable to click a link present inside the frame of a frameset
» Help me to get dynamicaly loaded options of dropdown in Selenium RC -Junit test case