Forum Discussion

mayursheth1's avatar
mayursheth1
Contributor
7 years ago

Unable to select the country name from dropdown

Hi Team,

 

am beginer to TestComplete and don't have much knowledge on programming.

 

Query:
On contacts section  i have 2 country dropdowns , when am spying it on first one which is mandatory in the section on first time it highlights properly but while running it selects the below country dropdown value.(PFA video for reference)

 

What i have tried:

1)Unable to Map as new object as this has been identified in different section and now in this section it shows (while spying) already exists.

2)Tried with Xpath but Click method is not showing for it.(below JS)

function OI()
{
var Page = Sys.Browser("chrome").Page("*");
Page.FindChildByXPath("//font[text()='Country of Registration :']//following::td//option").Click();

}

 

Gives attached error message.

 

Please let me know if any actions/Methods available in TC which i can use it to identify uniquely.

 

Thanks in Advance :)

Mayur Sheth

 

15 Replies

  • shankar_r's avatar
    shankar_r
    Community Hero

    Hi,

     

    How many objects you are seeing //font[text()='Country of Registration :']//following::td//option  this xpath in your browser window? like in console

     

     

    • mayursheth1's avatar
      mayursheth1
      Contributor

       

      Its showing 502 items , but even am not able to click on the dropdown list first then i can try to select the countries from dropdown.

       

      Please suggest if any other options.

      • shankar_r's avatar
        shankar_r
        Community Hero

        try using below xpath instead of yours and see how it works.

         

        //font[text()='Country of Registration :']//following::td/select

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi Mayur,

     

    > Tried with Xpath but Click method is not showing for it.

    This is one of many XPath disadvantages in TestComplete's world: depending on whether or not it was possible to match the object found by XPath with the object from TestComplete's objects tree (the one displayed in the Object Browser), XPath search will return either TestComplete's wrapping object or the native DOM one. .Click() is a method provided by TestComplete and is not accessible for the native DOM object.

    Two options are possible:

    a) Use TestComplete-provided search functions (.FindXXX() ones), which is preferable; or

    b) Try to use native .click() method instead of .Click() one (JScript is case-sensitive language).