get the value

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
Posts: 6
Joined: Wed Aug 27, 2014 10:43 am

get the value

Post by pvikramsharma » Thu Aug 28, 2014 8:02 am

What I am trying to code is

1. I want to add the first product into Basket from the promotion page


1. The products are differentiated as product_1_1_<then some unique number> and similarly second one will be product_1_2_<another unique number>.
2. I want a code where in I can retrieve the complete id of first product i.e. "product_1_1_301974"
3. use that unique number(301974) and click on the "Add" button which is identified with RXPath as /dom[@domain='']//a[#'p_301974_1'] .

Any solution for this.

The webpage in test is ... ormal,1651

Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: get the value

Post by krstcs » Thu Aug 28, 2014 2:40 pm

If the number is the product ID, you could pass that number into your module and then make the XPath with a variable and regex.


This would find the atag element that has the id attribute that contains the pattern like the product id you passed in.

I would suggest that you should know before-hand which product ID you are going to use, so that should be part of your test data. If you do that, you can make tests with different product sets without changing the code or paths.
Shortcuts usually aren't...

Posts: 6
Joined: Wed Aug 27, 2014 10:43 am

Re: get the value

Post by pvikramsharma » Thu Aug 28, 2014 2:58 pm

In the above example the product_id might change next week but only part of it will remain same

For example if the current producid is product_1_1_301974, in this the first part of the id will remain constant i.e. product_1_1(i.e. first 1st row 1st column item) and second half might change next week.

So I want to extract the final part i.e. 301974 and then use it further. I am kind of not getting the idea to extract the last part of the product_id

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA

Re: get the value

Post by Support Team » Fri Aug 29, 2014 2:09 pm

Hi pvikramsharma,

This sounds be a task for the Split() method of the String class: String Class.
Additionally, here are some links to pages where you can see how to split the strings: How to: Split Strings and C# Split.

You just need to save the value of the specific attribute to a module variable in advance, you could use the GetValue action to get the value of the attribute.