This is a migrated thread and some comments may be shown as answers.

Coded step

3 Answers 40 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Karol
Top achievements
Rank 1
Karol asked on 03 Jan 2014, 01:14 PM
Hi All,

I would like to use only native Studio functionality and have two nooby questions.

1. How to send data to source DB from coded step (have already DB connection defined - I use DSN connection to mysql)?
Is there a simple method to run just pure insert query?
All I have found are few Visual Studio methods and JS which seems to be a problem for me as I act as a client only and cannot add my JS to the WebPage (requirenment from Invoking JavaScript page:http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/write-tests-in-code/advanced-topics/javascript/invoking-javascript.aspx)

2. How to retrieve value to some variable from page element
Example:
I have page called KarolPortfolio and element called Balance in the hierarchy on the right in my Telerik Studio.
In the recorded step it is defined as a primary target: /KarolPortfolio/Balance
Balance is an element found using find syntax: tagname is exactly strong and class is exactly balance

Is there a way to run something similar to this code?
Dim balance as string = KarolPortfolio.Balance.ToString

As a last step I want to send this Balance to the DB table that is defined in the first step.
regards
Karol



3 Answers, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 07 Jan 2014, 09:03 PM
Hello Karol,

How to send data to source DB from coded step?

Just to make sure I understand, you want to put data from the test directly into the DB (not via a web app or something similar)? This can only done using .NET code. We have two code samples that demonstrate reading from a DB. You'll need to figure out how to adapt them for your needs:
  • http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/code-samples/general/access-sql-database.aspx
  • http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/code-samples/general/access-oracle-database.aspx

I don't see how JavaScript even comes into the picture for this. You wouldn't use JavaScript to make MySql DB queries.

How to retrieve value to some variable from page element

For code we have our auto-generated Pages class. All elements are added to this Pages class so that you can reference your elements from code. Given the description you should be able to get the text content of that HTML <strong> element using code something like this:

Dim balance as string = Pages.KarolPortfolio.Balance.TextContent

Note the structure. The syntax will always follow this pattern:
Pages.<page name>.<element name>.<property or method>

Regards,
Cody
Telerik
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Karol
Top achievements
Rank 1
answered on 07 Jan 2014, 09:41 PM
Hi Cody,

Thanks a lot for Your help.
In the mean time (during whole weekend :( wrrr) I manage to find how to connect to the DB.

For the second question I use a different method as Pages.KarolPortfolio.Balance.TextContent did not return correct value - do not ask me why :)
In an auto step I extract Inner Text to DataBindVariable and in a coded script I use MyBase.GetExtractedValue()

Works.
I have to only clean string, convert to double and done :)

regards
Karol
0
Cody
Telerik team
answered on 09 Jan 2014, 08:16 PM
Hello Karol,

That's great! Sounds like you got your problems solved then.

Regards,
Cody
Telerik
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Karol
Top achievements
Rank 1
Answers by
Cody
Telerik team
Karol
Top achievements
Rank 1
Share this question
or