Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
geek
Posts : 4
Join date : 2009-08-10

How to get the element path  like href Empty How to get the element path like href

Mon Aug 10, 2009 7:31 pm
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
Advisor
Advisor
------------------------
------------------------
Posts : 387
Join date : 2009-07-30
Location : India
https://seleniumforum.forumotion.net

How to get the element path  like href Empty Re: How to get the element path like href

Tue Aug 11, 2009 11:13 am
Hi,

First of all welcome and thanks to join this forum. Very Happy

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
avatar
geek
Posts : 4
Join date : 2009-08-10

How to get the element path  like href Empty Re: How to get the element path like href

Tue Aug 11, 2009 1:04 pm
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.
Advisor
Advisor
------------------------
------------------------
Posts : 387
Join date : 2009-07-30
Location : India
https://seleniumforum.forumotion.net

How to get the element path  like href Empty Re: How to get the element path like href

Tue Aug 11, 2009 2:16 pm
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.
avatar
geek
Posts : 4
Join date : 2009-08-10

How to get the element path  like href Empty Re: How to get the element path like href

Wed Aug 12, 2009 2:22 pm
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
avatar
geek
Posts : 4
Join date : 2009-08-10

How to get the element path  like href Empty Re: How to get the element path like href

Wed Aug 12, 2009 4:29 pm
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
Advisor
Advisor
------------------------
------------------------
Posts : 387
Join date : 2009-07-30
Location : India
https://seleniumforum.forumotion.net

How to get the element path  like href Empty Re: How to get the element path like href

Wed Aug 12, 2009 5:58 pm
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
Sponsored content

How to get the element path  like href Empty Re: How to get the element path like href

Back to top
Permissions in this forum:
You cannot reply to topics in this forum