How to select value from a dropdown present in a web table
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is how it looks when i record it
panel4.table.cell2.textnode.Click(59, 15) panel4.textnode.Click(42, 15)
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Were you able to spy the dropdown object, if yes then
- Take the properties of the dropdown object,
- Loop thru each cell and identify which has to have dropdown with the use of properties
- 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”- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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]")
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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”- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Create two project variables named (rowIndex, columnIndex)
- Edit the RowIndex object property and change it project variable and select the rowIndex Variable
- Edit the ColumnIndex object property and change it project variable and select the columnIndex Variable
- 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”- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot for giving a solution. Option 1 worked perfectly fine
Also is there a way to select a value from the dropdown rather than doing the keys. Would the findchild method work here
