Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» FlexMonkium Download Not available under Gorillalogic site
Thu Dec 08, 2016 5:40 pm by bhanu.praveen

» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

How to get the element path like href

View previous topic View next topic Go down

How to get the element path like href

Post by geek on 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

geek

Posts : 4
Join date : 2009-08-10

Back to top Go down

Re: How to get the element path like href

Post by Adviser on 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

Adviser
------------------------
------------------------

Posts : 379
Join date : 2009-07-30
Location : India

http://seleniumforum.forumotion.net

Back to top Go down

Re: How to get the element path like href

Post by geek on 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.

geek

Posts : 4
Join date : 2009-08-10

Back to top Go down

Re: How to get the element path like href

Post by Adviser on 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.

Adviser
------------------------
------------------------

Posts : 379
Join date : 2009-07-30
Location : India

http://seleniumforum.forumotion.net

Back to top Go down

Re: How to get the element path like href

Post by geek on 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

geek

Posts : 4
Join date : 2009-08-10

Back to top Go down

Re: How to get the element path like href

Post by geek on 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

geek

Posts : 4
Join date : 2009-08-10

Back to top Go down

Re: How to get the element path like href

Post by Adviser on 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

Adviser
------------------------
------------------------

Posts : 379
Join date : 2009-07-30
Location : India

http://seleniumforum.forumotion.net

Back to top Go down

Re: How to get the element path like href

Post by Sponsored content Today at 1:04 pm


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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