Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using DP with variables
#1
Solved: 10 Years, 9 Months ago
Hi, i am new in this forum, I am from Argentina, sory if you don´t understand completely what i write.

I am using DP programming cause a web page have identical objects. I read that the correct form is using the parameter index or location, i chose index.
Descripting an object, is not posible to use variables as a description of the object am i right?

Example working:

Code:
aux=Environment.Value("ActionIteration")-7
    If (aux=0) Then
        Browser("Browser").Page("Page_4").Link("name:=Unicef -","html tag:=A","text:=Unicef -","Index:=0").Click
    End If

    If (aux=1) Then
        Browser("Browser").Page("Page_4").Link("name:=Unicef -","html tag:=A","text:=Unicef -","Index:=1").Click
    End If

Example NOT working:
Code:
aux=Environment.Value("ActionIteration")-7
Browser("Browser").Page("Page_4").Link("name:=Unicef -","html tag:=A","text:=Unicef -","Index:=aux").Click

The 2nd way is much better cause i can add new rows in the dataTable without touching the code, but it doesn´t work for me, what i am doing wrong? Is there any way to do what i am looking for?

Thanks
Reply
#2
Solved: 10 Years, 9 Months ago
as 'aux' is variable you can not use it within double quotes, use concatenation when use this way, see below -
Code:
Browser("Browser").Page("Page_4").Link("name:=Unicef -","html tag:=A","text:=Unicef -","Index:=" & aux).Click

hope this helps.

Reply
#3
Solved: 10 Years, 9 Months ago
If the line of code given by Saket does not work, Try this:
Code:
Browser("Browser").Page("Page_4").Link("name:=Unicef -","html tag:=A","text:=Unicef -","Index:=" & Cstr(aux)).Click
Reply
#4
Solved: 10 Years, 9 Months ago
What Saket is telling is absolutely right ,if we are passing a variable can not use it within double quotes, use concatenation

You can use the below code...

Code:
aux=Environment.Value("ActionIteration")-7
aux=Cint(aux)
Browser("Browser").Page("Page_4").Link("name:=Unicef -","html tag:=A","text:=Unicef -","Index:=" & aux).Click
Reply
#5
Solved: 10 Years, 9 Months ago
@Sasmita: In your post, why do you think CStr should be used instead of Cint where (Environment.Value("ActionIteration")-7)
would return a Numerical value which would be assigned to Index.
Reply
#6
Solved: 10 Years, 9 Months ago
Thanks to all, works great without cstr.
Reply
#7
Solved: 10 Years, 9 Months ago
Same thing in many different ways,
requesting all to not to confuse our freinds who are beginners, with your so many replies on same things.
Please wait for the original poster to reply first, or if you have a better solution.

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Function That Creates WebLink Variables Eitel13 3 1,228 07-17-2018, 03:25 PM
Last Post: Ankur
  Array as User-Defined Environment Variables Arena 3 4,139 04-16-2012, 09:19 AM
Last Post: sshukla12
  programming to use different external file of environment variables bundfromnj 1 3,703 01-19-2012, 05:32 PM
Last Post: SteveS
  How to store all output values in different variables Jyobtech 4 4,442 10-13-2010, 11:23 AM
Last Post: KavitaPriyaCR
  Why Constant Variables while connecting to DB mona 4 4,738 07-27-2009, 02:16 PM
Last Post: mona

Forum Jump:


Users browsing this thread: 1 Guest(s)