Ask a Question

condition of Delay method if there are chance of exist two different pages in automation

kaiiii
Regular Contributor

condition of Delay method if there are chance of exist two different pages in automation

In the below i am trying to call delay for two different pages, if any one of them will exist it should be work but i am getting error when declaring object2.Exists = True.... Please help

 

 

Function callDelay(time,PropertyName, KeyValue, TagName)
Dim counter
'Delay Function using Counter Applied for PageLoading and calling home page .
Set page = Sys.Browser("*").Page("*")
Do
aqUtils.Delay 1000
Set object 1 = page.NativeWebObject.Find(PropertyName, KeyValue, TagName)

Set object2  = page.NativeWebObject.Find(PropertyName, KeyValue, TagName)
counter = counter+1
Loop Until object1.Exists = True or object2.Exists = True or counter >= time

If counter >=time then
       Log.Error("Page can not be loaded......")
       counter=0
       page.FindChildByXPath("//a[@href='login.htm']").Click
Else
       Log.Message("Time taken to : "&object.contentText&" "&counter&" Seconds")
End If
End Function

7 REPLIES 7
baxatob
Community Hero

 

Set page = Sys.Browser("*").Page("*")

 

The code above will recognize ANY page. If you have two pages, the Find() method will always work on the first page, that was found in the ObjectBrowser tree.

 

You need to recognize the proper page before you run any methods their.

kaiiii
Regular Contributor

What method i can use in place of Find() Method so that, i can make a logic to search both object on different pages

Find() method is good enough. 

 

Can you describe your test case step by step? We'll try to find a solution.

kaiiii
Regular Contributor

 

Set Document  =  page.NativeWebObject.Find("id", "skipUploadDocumentId", "p")

 

Set Registration_Confirm  =  page.NativeWebObject.Find("id", "inactive_div_id", "div")

 

After performing an action.. one of them object would be show on the next page.. so i have to put a delay

Here i am using the logic please check

 

Function callDelay(time,PropertyName, KeyValue, TagName)
Dim counter
'Delay Function using Counter Applied for PageLoading and calling home page .
Set page = Sys.Browser("*").Page("*")
Do
aqUtils.Delay 1000
Set Document = page.NativeWebObject.Find(PropertyName, KeyValue, TagName)

Set  Registration_Confirm  = page.NativeWebObject.Find(PropertyName, KeyValue, TagName)
counter = counter+1
Loop Until Document.Exists = True Or Registration_Confirm  .Exists = True Or counter >= time

If counter >=time then
       Log.Error("Page can not be loaded......")
       counter=0
       page.FindChildByXPath("//a[@href='login.htm']").Click
Else
       Log.Message("Time taken to : "&object.contentText&" "&counter&" Seconds")
End If
End Function

 

 

after calling this method i supposed to work but i am not getting the result

 

Function callDelay(time,PropertyName, KeyValue, TagName)
   ...
   Set Document               = page.NativeWebObject.Find(PropertyName, KeyValue, TagName)
   Set  Registration_Confirm  = page.NativeWebObject.Find(PropertyName, KeyValue, TagName)
...

 

Within the scope of the above function Document and Registration_Confirm objects are the same, because they are using the same arguments.

kaiiii
Regular Contributor

Hi, i got your point

will it work if i use different argument for 2nd object ??

i mean if i use Title or something extra

Give a try. 

 

But on my point better to separate finding of elements. Like:

 

 

//p s e u d o c o d e

function MyFind(Property, Value, Timeout) {
  return page.WaitProperty(Property, Value, Timeout)
  }


function MyTest() {
  someAction()
  if MyFind(Property1, Value1, Timeout) {
    doSomething()
    }
  elif MyFind(Property2, Value2, Timeout) {
    doSomethingElse()
    }
else {
Log.Warning("Nothing was found")
{ }

 

 

 

cancel
Showing results for 
Search instead for 
Did you mean: