Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QTP not selecting appropriate webelement from the webtable..Need Solution
#1
Solved: 11 Years, 4 Months, 4 Weeks ago
Code:
Browser("browsername").Page("Inpatient").Frame("Admission Requests").WebElement("innertext:=AR1100000113", "html tag:=SPAN", "html id:=AppointGrid_Datagrid_ROWS_DATA_1_3").Click
Browser("browsername").Page("Inpatient").Frame("Admission Requests").Image("confirm_on").Click

I have recorded the script for selecting the weblement(using click method) from the webtable and for performing next operation on the selected line

But while running the script it is selecting different webelement(first statement) and performing next operation for first statment in the webtable(i.e., not selecting the appropriate webelement)

I tried to find the solution but got invain

Please help me out ASAP

Please refer the attachments for easy understanding


Attached Files Image(s)
           
Reply
#2
Solved: 11 Years, 4 Months, 4 Weeks ago
use webtable methods instead accessing webelements directly.
try below steps to achive this -
1. get the row where your required text is there in the table using GetRowWithCellText
nRow =B().P().F().WebTable().GetRowWithCellText("AR1100000113")
2. set an object to the webelement of the row and required column
Set oElem = B().P().F().WebTable().childitem(nRow,4,"WebElement",0)
3. Click on webelement
oElem.Click

Reply
#3
Solved: 11 Years, 4 Months, 4 Weeks ago
Hi Saket,

May i know the reason for using '4' in childitem(nRow,4, "WebElement",0)

i ran the script which you gave but its giving error as statment contains one or more invalid function arguements..please help me out

Thanks in advance

Sorry Now there is no error appeared to me but at the sametime no action takes place..I have used your code as below..


Code:
Set AdmissionRequests = Browser("browsername").Page("Inpatient").Frame("Admission Requests")
nrow = AdmissionRequests.WebTable("Requested Admission Date").GetRowWithCellText("AR1100000113")
PRINT r
c = AdmissionRequests.WebTable("Requested Admission Date").ColumnCount(nrow)
PRINT c
Set oElem = AdmissionRequests.WebTable("Requested Admission Date").ChildItem(nrow, c, "WebElement", 0)
oElem.Click

O/P values:
r=4
c=1
Reply
#4
Solved: 11 Years, 4 Months, 4 Weeks ago
'4' in childitem statement is the column number where you wbelement is in the row.
you have used it as 'c' later, but it will contain the number of columns in the specified row by using your statement as 'WebTable("Requested Admission Date").ColumnCount(nrow)' use the column number where webelement is present there.

Reply
#5
Solved: 11 Years, 4 Months, 4 Weeks ago
Hi Saket,

Actually webtable has 9 rows and 1 column as is is displayed in object spy(attached here) and if i pass number directly in childitem(eg: column number as 4) then it is giving run time error when i run the below script

Code:
Set AdmissionRequests = Browser("BN").Page("Inpatient").Frame("Admission Requests")
r = AdmissionRequests.WebTable("Requested Admission Date").GetRowWithCellText("AR1100000113")
PRINT r
Set oElem = AdmissionRequests.WebTable("Requested Admission Date").ChildItem(r, 4, "WebElement", 0)
oElem.Click

Error:
----------------------------------------------------------------
The statement contains one or more invalid function arguments.
Line (173): "oElem.Click".
----------------------------------------------------------------

Webtable is not having equally distributed rows and columns...this is the problem i guess..

Please help me out with any other solution

Please refer the attachments...

Thanks,
satish
Reply
#6
Solved: 11 Years, 4 Months, 4 Weeks ago
Guyz,

Please help me ASAP which is highly appreciated..waiting for ur reply

Thanks,
Satish
Reply
#7
Solved: 11 Years, 4 Months, 4 Weeks ago
what do you mean by "not equally distributed", are you able to get the column number for Requisition Number?

there could be one more way - you just need to select the required row and proceed, right? see if this can be done by clicking the webelement at first column. if so dont bother to retrive the column number just try with 1.

let me know if that works.

Reply
#8
Solved: 11 Years, 4 Months, 4 Weeks ago
Code:
Set AdmissionRequests = Browser("BN").Page("Inpatient").Frame("Admission Requests")
r = AdmissionRequests.WebTable("Requested Admission Date").GetRowWithCellText("AR1100000113")
PRINT r
Set oElem = AdmissionRequests.WebTable("Requested Admission Date").ChildItem(r, 1, "WebElement", 0)
oElem.Click

I tried with first column even then its not meeting as expected(no weblement is clicked)

what i mean to say is in fronend of the application table is showing with some n number of columns and m number of rows but in the object spy only one column and some 9 rows is displayed in the properties
Reply
#9
Solved: 11 Years, 4 Months, 4 Weeks ago
Hi...
Can u plz try this and see if the expected cell is getting highlighted properly?

Code:
Set AdmissionRequests = Browser("BN").Page("Inpatient").Frame("Admission Requests")
r = AdmissionRequests.WebTable("Requested Admission Date").GetRowWithCellText("AR1100000113")
PRINT r
Set oElem = AdmissionRequests.WebTable("Requested Admission Date").ChildItem(r, 1, "WebElement", 0)
oElem.Highlight  ' it will just highlight the webelement
Reply
#10
Solved: 11 Years, 4 Months, 4 Weeks ago
when i use the above script then it is highlighting entire table..


I have modified the script as below and tried again but still not selecting appropriately
Code:
Set AdmissionRequests = Browser("BN").Page("Inpatient").Frame("Admission Requests")
r = AdmissionRequests.WebTable("Requested Admission Date").GetRowWithCellText("AR1100000113")
PRINT r
Set oWebElement=Description.Create()
oWebElement("micclass").value="WebElement"
oWebElement("innertext").value = "AR1100000113"
Set oElem = AdmissionRequests.WebTable("Requested Admission Date").ChildObjects(oWebElement)
obj = oElem.count
PRINT obj
res = abs(obj - r)
res1 = abs(obj - res) - 1
If AdmissionRequests.WebTable("Requested Admission Date").Exist(1) Then
    oElem(res1).Click
End if
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Exclamation WebElement("WebElement").Click is not working sia sharma 7 24,026 09-28-2016, 08:58 PM
Last Post: supputuri
  Scrambled characters in uft Solution Explorer Dwarak Calayampundi 0 1,561 05-25-2016, 05:02 AM
Last Post: Dwarak Calayampundi
  QTP not recording script for webtable alpha1 4 2,941 07-20-2015, 03:47 PM
Last Post: alpha1
  Selecting values from drop down using QTP. prempujaripati 2 46,844 06-26-2014, 06:06 PM
Last Post: rasmirani
  Selecting file saved in a location excellentpawan 1 4,079 02-25-2014, 02:05 PM
Last Post: guin.anirban

Forum Jump:


Users browsing this thread: 1 Guest(s)