What I am trying to code is
1. I want to add the first product into Basket from the promotion page
Problems
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='bigbasket.com']//a[#'p_301974_1'] .
Any solution for this.
The webpage in test is http://bigbasket.com/promo/attaractive- ... ormal,1651
get the value
Re: get the value
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.
//a[@id~$ProductID]
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.
//a[@id~$ProductID]
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
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
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
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: get the value
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.
Regards,
Markus
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.
Regards,
Markus