Ask a Question

Issue to find grid text box location

SOLVED
sanjib
Occasional Contributor

Issue to find grid text box location

Hi friends,

I am using new Trial version of Test Complete.

and  using 'Record Script (JavaScript)' in a web based application.

I found a specific issue to find out the location of Grid Text box.

On process of testing, there are text boxes in Grid which name is dynamically changing on each time running the web application.

Example --when I recorded first time the text box name as recorded in script as below,

 

page.FindElement("[role='dialog']:nth-child(12) .ui-button-text").Click();
textbox = page.FindElement("#txtColumnTitle_12");

 

But when I am running same Script, the name of the text box is changed like 

textbox = page.FindElement("#txtColumnTitle_17");

So, it could not able to find the element as it suffix number is changed .

How can i overcome this issue?

 

Please let me know if it make clear for all of you to response effectively. 

 

 

 

 

8 REPLIES 8
Marsha_R
Champion Level 3

You can use wildcards in your script in order to make the object name match ones that are similar.

https://support.smartbear.com/testcomplete/docs/reference/misc/using-wildcards.html

sanjib
Occasional Contributor

Hi Marsha_R,

Thank you for your prompt reply.

 I tried this way as below, 

textbox = page.FindElement("#txtColumnTitle_*")

Inseated of 

textbox = page.FindElement("#txtColumnTitle_12").

It s not worked , 

 

I am not sure that I did appropriately!

If you any further suggestion, it will be helpful.

Marsha_R
Champion Level 3

What happened when you tried that?  A screenshot of the error would be helpful.

 

 

sanjib
Occasional Contributor

Thank you, hope this will help,

 

sanjib_0-1615438099682.png

 

sanjib_1-1615438192487.png

 

 

Marsha_R
Champion Level 3

The error message is telling you that you have too many browsers open and TestComplete can't understand where you want it to run the test.  Best practice is to start with all browsers closed and launch the one you want to test at the top of your test.

 

https://support.smartbear.com/testcomplete/docs/app-testing/web/general/common-tasks/launching-brows...

 

sanjib
Occasional Contributor

Thank you, I will try again .

AlexKaras
Champion Level 3

Hi,

 

textbox = page.FindElement("#txtColumnTitle_*")

While Marsha is correct as for the note about ambiguous browser, your line of code still will not work.

The syntax with wildcard that you are trying works only for the cases when native TestComplete's search functionality is used.

.FindElement() uses not TestComplete's native but XML/CSS native search functionality that does not support wildcarding in the form that you tried.

As you are searching by CSS, you may try (and check whether it works or not - I did not try it) something like this:

http://www.brendanconnolly.net/css-wildcard-selectors/

https://www.google.com/search?q=css+wildcard+search

 

Regards,
  /Alex [Community Champion]
____
[Community Champions] 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 Champions]
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 Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
sanjib
Occasional Contributor

Dear Alex,

Thank you for very effective suggestions.

I will look on those.

cancel
Showing results for 
Search instead for 
Did you mean: