dynamic table values
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
dynamic table values
Hello everybody!
I would like to ask you what is the best way for coding a function in Java script for choosing (click) a value into a dynamic table?
Thank you for helping me in advance.
Best regards
lambada
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you try Find() method?
function choose_value( value ) { Aliases.browser.page.Find( 'contentText', value, 10 ).Click();
}
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your answer. Actually, no I didn´t try it.
contentText means in this case name123? Or do I have to look up into the properties of name123? Why value, or what exactly it means (actually my needed value is a string)? And why 10?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
> Why value, or what exactly it means [...]
Tools by SmartBear have excellent documentation available online and offline. This documentation is really worth reading and this is the reason of why replies on this forum quite often reference this or that help topic. For this particular case, reading documentation for .Find()/.FindChild() method had to made it clear what is the 'value' and 10 parameters.
> but now I should write a script
The easiest and fastest way is to turn on (script) recording in TestComplete, record required actions and analyze the recorded result. Use Object Browser in TestComplete to understand what and why was recorded. Then modify recorded code as per your needs.
As I already wrote, exact implementation depends on the design of your tested web page. And until you let us know its structure, no one will likely provide you with the code sample.
Right now, your request sounds like 'How to drive?'. While there is a small chance that someone will describe how to drive a bike and a car and a truck and F1 bolide, and a yacht, most likely that first you will be asked to let the guys know what exactly would you like to drive, will you drive for yourself or as a professional driver, etc.
So, read referenced help topics, check videos from the https://support.smartbear.com/screencasts/testcomplete/ page, try recording and examine the tested page using Object Browser.
/Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@baxatob thank you, I will try it!
@AlexKaras thank you, I will try it. Of course I have recorded it first to see how test complete is dealing with it, but the recorded Java sript contains clicking at a position and not at the expected value. And because this value changes its position I have to write a function by myself, so I was asking if anybody can help me to write a code (Java script). The logic I understand, now I should get the practice.
Later I will give you a feedback. Thank you guys!
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
> the recorded Java sript contains clicking at a position and not at the expected value.
Why not to provide a piece of recorded code with your comments? This well could be saving you several days and save our time as well. 🙂
Use Object Browser. Object Browser is you primary tool for UI testing in TestComplete. If something is identified in the Object Browser then it can be interacted with from test code. If something is not identified in the Object Browser, but you know that it exists in the tested application, then either you must find a way to make it to be identifiable in the Object Browser or to find a way to do what you need but without interacting with this entity.
So, use Object Browser, explore your tested page, make a mental correlation between the layout rendered on screen with its internal structure displayed in the Object Browser, talk to developers and ask them to describe you what tools/technologies they used to create the tested page to get better understanding of how internal page objects relate to each other to provide you with the visual experience that you have from the page. This all must help you to understand what and how should be coded in your test code and this is what is required from you here before someone can provide you with some more or less meaningful and relevant code sample.
/Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks to you.
I am not sure if I am permitted to share my recorded code, but I agree with you, that would be the best.
Test Complete is doing:
function (){
var browser;
... //here are some other vars
var panel;
browser.BrowserWindow.Click(149, 52); //when I click for typing the webpage www.
browser.pageWww ... .Keys("... [Enter]"); //typing the webpage www. and I press enter
... //here are some other test steps
panel.table.cell.Click(36, 19);
... //here are some other test steps as well
}
instead of "panel.table.cell.Click(36, 19);" the code should contain something with "name123" beacuse the position changes. Few days later, if I would let the test case play, and TesComplete would execute "panel.table.cell.Click(36, 19);" the test case would fail becaus at the position "panel.table.cell.Click(36, 19);" I wouldn´t find "name123" anymore because the dynamic table changes (some other values will be created meantime).
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are using the bad practice. The recorder will always return a click by coordinates, however you should avoid it. So the best you can do is not to use recorder and write code by yourself.
Each Click(x, y) is a step to hell 🙂
P.S. Typing URL using Keys() is also not good approach. Navigate() method is much more better solution - https://support.smartbear.com/testcomplete/docs/reference/test-objects/controls/web/general/browseri...
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
> I am not sure if I am permitted to share my recorded code
I am not sure that your first recorded code is that confidential. 🙂 But if it is, then you should either create Support ticket via the https://support.smartbear.com/message/?prod=TestComplete form (SmartBear considers NDA signup when asked by the customer) or find a way to clearly describe the problem here. I am not aware about oracles on this forum who can understand the problem just by its generic description.
> //when I click for typing the webpage www.
@baxatob already replied that direct address typing is not the best practice because it is less robust then navigational methods provided by the Browser object in TestComplete.
https://support.smartbear.com/testcomplete/docs/app-testing/web/general/common-tasks/index.html may be useful as well.
> panel.table.cell
This makes me guess (just to guess as you are not willing to provide us with the Object Browser screenshot that contains the internal structure of the table on the tested page) that the tested table has a classic markup with the cells inside it.
https://support.smartbear.com/testcomplete/docs/app-testing/web/general/examples/parsing-html-tables... may help with the example of how to iterate through table's cells.
/Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi guys, thank you for your answers and sorry for that late response from my side.
Now I have created a simulation that has the same idea as I need for.
I need: Test complete should go to the list number 3 (blue one) and go through the table value until testcomplete pick up the value "Anna10" (that is now at the position 10). Because Annas are in alphabetic order, I could create, with the help of AO1, Anna0. Anna0 would be then at first, so Anna10 would slip off at the position 11.
I hope now it is clearer?
Can anybody help me to write the code please?
