Micro Focus QTP (UFT) Forums

Full Version: Script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I want the system to click on a link "Apply", but if that link doesn't exist I want the system to click on a link "Close".

The "test" is applying for a job and if the "test" has already applied for just that job, the button "Apply" doesn't exist.

I have written following

Code:
If
Browser("Njord Web Portal - Job_2").Page("Njord WebPortal - Job").Link("Apply") Then .Click

Else
Browser("Njord Web Portal - Job_2").Page("Njord Web Portal - Job").Link("Close").Click

End If

[/i]but I receive Syntax error. Why?

I'm greatful all tips I can get.

Ann Hagglund
Hi,
write it as
Code:
If Browser("Njord Web Portal - Job_2").Page("Njord WebPortal - Job").Link("Apply").Exists Then
     Browser("Njord Web Portal - Job_2").Page("Njord WebPortal - Job").Link("Apply").Click
  Else
     if Browser("Njord Web Portal - Job_2").Page("Njord Web Portal - Job").Link("Close").Exists Then
            Browser("Njord Web Portal - Job_2").Page("Njord Web Portal - Job").Link("Close").Click
     end if
  end if
Hi,

The If condition in Else can be omited.
Hi again,
Thank you for your quick answer but unfortunately I receive an error message in accordance to my attachment:
this error is related to page object which is not found in the object repository . once this object found then use :
Code:
B().P().Webedit().Type Date
or
B().P().Webedit().Type "20/04/2011"
or
B().P().Webedit().Type "20042011"
Hi Ann,

Use if condition to click on the link.

Code:
If Browser().Page().Link().Exists(5) Then

Browser().Page().Link().Click

End If

Note: Add Objects to OR Before you run above script.


Thanks,
[/quote]Hi again,
I have now stated that the object is in Object repository but now I receive the following error message: See attachment.


Hi again,
I received an error message regarding that the object doesn't support...., see below.

Another question, I am a real beginner, what do you mean with
"Add Objects to OR Before you run above script".

Sorry to bother you again!

Thank you for your help!!!
Ann Hagglund
Adecco Sweden


Hi again,
I know what OR means. Sorry for that. The object is already in Object Respository, I have checked that.


Best regards,
AnnSmile
Hi,
Sorry.... It's link().Exist instead of link.Exists Tongue
Hi again!
I'm so happy, it works now. Thank you for all your help!Smile

Hi there!

You're welcome . this helps in resolving your issue.

Have a great day!
Thank you !!!
UFTEnthusiast