Ask a Question

Reference to an HTML object having a string with his mapped name

SOLVED
lodecesa
Contributor

Reference to an HTML object having a string with his mapped name

Hi to all, I have the mapped name of an HTML object in a string and I want find its reference with a method like this:

 

var elementReference = Aliases.browser.page.form.byName(mappedName);

 

Thanks to all

5 REPLIES 5
rraghvani
Trusted Contributor

See Find Mapped Objects by Aliases, WaitAliasChild Method

 

Can you not use?

var elementReference = Aliases.browser.page.form.mappedName;

 

AlexKaras
Community Hero

Hi,

 

Assuming that you have:

var aStr = "Aliases.browser.page.form.mappedName";

Are you looking for this:

var anObj = eval(aStr);

?

 

Regards,
  /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
================================


@AlexKaras wrote:

Hi,

 

Assuming that you have:

var aStr = "Aliases.browser.page.form.mappedName";

Are you looking for this:

var anObj = eval(aStr);

?

 


Yes, this solution works as I was suggested by ChatGPT after several attempts. The final form I used is this:

 

function (elementAlias) {

  // The prefix to be added before the alias of the element
  var aliasPrefix = "Aliases.browser.page.form.";

  // Retrieve the element through the alias
  var element = eval(aliasPrefix + elementAlias);

  // Interact with the element
  element.Click();

}

 

Hi,

 

as I was suggested by ChatGPT after several attempts.

Funny 🙂

Just curious what your request succeeded? (I.e. whether ChatGPT already processed this Community or it was solution from some other forum/for some other language.)

 

Regards,
  /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
================================


@AlexKaras wrote:

Hi,

 

as I was suggested by ChatGPT after several attempts.

Funny 🙂

Just curious what your request succeeded? (I.e. whether ChatGPT already processed this Community or it was solution from some other forum/for some other language.)

 


Hello,

to be honest, it is not very knowledgeable about TestComplete, often providing incorrect or inapplicable solutions, probably its information on the subject is scarce and incomplete.

(This post is its translation from italian) 😁

cancel
Showing results for 
Search instead for 
Did you mean: