Hi,
I'm having problem with the extraction and then parse this extraction and use it in input value field. On the site there is a table with results from which I want to pick random cell in first column and store this data (example value in cell ZVE-P5045-2892). Then I want to take last digits after the second "-" sign (example 2892) and type it in the input value field on the page. If I try the following, I get the whole value ZVE-P5045-2892 into the input field:
1. Extract 'TextContent' on 'ZVEP50452892TableCell' into DataBindVariable $(paymentRequest)
2. Enter text 'zve-p5045-2892' in 'NumberText' - DataDriven: [$(paymentRequest)]
I know I have to use VB.NET now, but as I lack of the VB knowledge I need your help. So how could I pick a random value from cell in first column, use only last 4 digits from this value and type it in to input value field?
Thanks and BR, Jurij
6 Answers, 1 is accepted
I tried also the following, but without success (before getting to this I need to also randomly pick a cell content):
'Enter text '2892' in 'NumberText'
Dim cellValue As String = paymentRequest '<- I have used databind variable name here, which I know is wrong, but that is exactly what I need to use
Dim payment As String
payment = cellValue.Substring(11, cellValue.Length -4)
Actions.SetText(Pages.SettlementsOurApp0.NumberText, payment)
BR, Jurij
I have tried the following as well without any success:
Dim cellValue As String = Pages.SettlementsOurApp0.ZVEP50452892TableCell.AssertContent().TextContent(ArtOfTest.Common.StringCompareType.Contains, "ZVE-P5045-2892")
Dim paymentNr As String
paymentNr = cellValue.Substring(11, cellValue.Length -4)
Actions.SetText(Pages.SettlementsWebSales0.NumberText, paymentNr)
Can anybody help me with this?
BR, Jurij
Please note that this is not Test Studio related problem but general programing question. You can take a look over the Internet on how to split strings using VB. I found the following articles which you might find useful.
http://stackoverflow.com/questions/17059971/vb-net-split-string
and
http://www.dotnetperls.com/split-vbnet
Regards,
Ivaylo
Telerik
I understand, but let me write again what I want to achive but don't know how I can do this in Test Studio.
I have a table with different results. I want to extract the value from first column in random row of this table and then use it in input value field.
Now if I use Test Studio Extract 'TextContent' on 'ZVEP50452892TableCell' into DataBindVariable $(paymentRequest) I get the value in the following output: ZVE-P5045-2892.
But to use it as an input, I have to have only last digits after the last "-" sign.
Is there any way to do this without VB? Can someone point me where I can find a way to randomly select a cell value from table, then use the value, parse it and then use it in another element?
I found a way to use VB to parse the vale, but I don't know what should I use to parse it? This doesn't work Dim cellValue As String = Pages.SettlementsOurApp0.ZVEP50452892TableCell.AssertContent().TextContent(ArtOfTest.Common.StringCompareType.Contains, "ZVE-P5045-2892").
What parameter, value, element can I use in VB code and how?
Please let me know, because this is really a show stopper for us.
BR, Jurij
Unfortunately as I noticed, this can be done only by using code and this has nothing to do with Test Studio. I am providing you a sample example on how you can get the last four symbols from the string you are using:
Dim
code
As
String
=
"ZVE-P5045-2892"
Dim
newcode
As
String
= code.Substring(code.Length - 4)
Hope this works for you.
Regards,
Ivaylo
Telerik
Hello Ivaylo,
But it does relate to Test Studio, because I was looking for this Dim cellValue As Object = GetExtractedValue("payRequest")!
I didn't know how could I use data bind variable extracted from Extract 'TextContent' on 'ZVEP50452892TableCell' into DataBindVariable $(payRequest) in the code...
Never the less thanks, but your suggestion wouldn't solved my problem.
BR, Jurij