cancel
Showing results for 
Search instead for 
Did you mean: 

How to select value from a dropdown present in a web table

SOLVED
Highlighted
Contributor

How to select value from a dropdown present in a web table

I'm able to retrieve value from a cell using the below code - 

form.panel4.table.rows.item(1).cells.item(8).innertext()

 

but looking for a solution to select the value from a dropdown present in one of the cells of webtable.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: How to select value from a dropdown present in a web table

This screen tells me what is going wrong,

 

Cell is the ObjectType and is not a callable function. This is what you can do.

 

Option #1

You can do like below

if(form.panel4.table.Exists){
        var propNames = ["ObjectType","RowIndex","ColumnIndex"];
        var propValues = ["Cell","1","8"];
        var cellObject = form.panel4.table.FindChild(propNames,propValues);
        
        if(cellObject.Exists){
            textNodeObj = cellObject.FindChild("textnode propnames","textnode propvalues");
            textNodeObj.click();
            textNodeObj.Keys("[Down]");
        }
    }

Option #2

 

  1. Create two project variables named (rowIndex, columnIndex)
  2. Edit the RowIndex object property and change it project variable and select the rowIndex Variable
  3. Edit the ColumnIndex object property and change it project variable and select the columnIndex Variable
  4. And try with below code
    Project.Variables.rowIndex = 1;
    Project.Variables.columnIndex = 8;
    
    if(form.panel4.table.Cell2.textnode.Exists){
        form.panel4.table.Cell2.textnode.click()
        form.panel4.table.Cell2.textnode.Keys("[Down]")
    }

 

Let me know if this works for you!

 

 


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”


Extension Available

View solution in original post

10 REPLIES 10
Community Hero

Re: How to select value from a dropdown present in a web table

Easiest way to find out is to record a test and walk through the steps that you want.

 

https://support.smartbear.com/testcomplete/docs/tutorials/getting-started/first-test/web/index.html

Contributor

Re: How to select value from a dropdown present in a web table

This is how it looks when i record it

panel4.table.cell2.textnode.Click(59, 15)
panel4.textnode.Click(42, 15)
Community Hero

Re: How to select value from a dropdown present in a web table

Were you able to spy the dropdown object, if yes then

  1. Take the properties of the dropdown object,
  2. Loop thru each cell and identify which has to have dropdown with the use of properties 
  3. Click on the drop down, try to find spy objects in the list and repeat the 1 and 2 cells.

More details on the object and screenshot would be better to help


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”


Extension Available

Contributor

Re: How to select value from a dropdown present in a web table

Thanks for your suggestion. This dropdown gets identified as a textnode and it would be present in the last column of all the rows. In the name mapping it is under the below heirarchy

form->panel->table->cell2->texnode. Property of cell has row and index

 

Dropdown.PNGNameMapping.PNG

 

 

 

 

 

 

 

Contributor

Re: How to select value from a dropdown present in a web table

for now i'm able to select some value from the dropdown with the below code

form.panel4.table.Cell2.textnode.click()
form.panel4.table.Cell2.textnode.Keys("[Down]")

But Cell2 is not the ideal way to do, since it has a particular row and column mapped to it.

tried with below code - but it is not working. I can pass the row and column as variables in the code

form.panel4.table.Cell(1,8).textnode.click()
form.panel4.table.Cell(1,8).textnode.Keys("[Down]")

 

Community Hero

Re: How to select value from a dropdown present in a web table

First thing first, do exists before any action on the object.

 

if(form.panel4.table.Cell(1,8).Exists){
     form.panel4.table.Cell(1,8).textnode.click()
     form.panel4.table.Cell(1,8).textnode.Keys("[Down]")
}

 If cell not exists then we can't do anything, 


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”


Extension Available

Contributor

Re: How to select value from a dropdown present in a web table

Yes i did try this, and got this error message. But when i do cell2 instead of cell(1,8) in the below code it does work fine.

cell2_NameMapping.PNG

 

Error.PNG

Community Hero

Re: How to select value from a dropdown present in a web table

This screen tells me what is going wrong,

 

Cell is the ObjectType and is not a callable function. This is what you can do.

 

Option #1

You can do like below

if(form.panel4.table.Exists){
        var propNames = ["ObjectType","RowIndex","ColumnIndex"];
        var propValues = ["Cell","1","8"];
        var cellObject = form.panel4.table.FindChild(propNames,propValues);
        
        if(cellObject.Exists){
            textNodeObj = cellObject.FindChild("textnode propnames","textnode propvalues");
            textNodeObj.click();
            textNodeObj.Keys("[Down]");
        }
    }

Option #2

 

  1. Create two project variables named (rowIndex, columnIndex)
  2. Edit the RowIndex object property and change it project variable and select the rowIndex Variable
  3. Edit the ColumnIndex object property and change it project variable and select the columnIndex Variable
  4. And try with below code
    Project.Variables.rowIndex = 1;
    Project.Variables.columnIndex = 8;
    
    if(form.panel4.table.Cell2.textnode.Exists){
        form.panel4.table.Cell2.textnode.click()
        form.panel4.table.Cell2.textnode.Keys("[Down]")
    }

 

Let me know if this works for you!

 

 


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”


Extension Available

View solution in original post

Contributor

Re: How to select value from a dropdown present in a web table

Thanks a lot for giving a solution. Option 1 worked perfectly fine Smiley Happy

Also is there a way to select a value from the dropdown rather than doing the keys. Would the findchild method work here