Closed GoogleCodeExporter closed 9 years ago
In VBA/VBS primitives are straightforward to assign to a variable:
Dim v1: v1 = 23
Dim v2: v2 = "text"
Dim v3: v3 = function_retrun_primitive()
Whereas objects require the Set keyword in front:
Dim v4: Set v4 = object
Dim v5: Set v5 = function_return_object()
The reason the switchToFrame is failing could be that you are providing the
wrong index.
Moreover, in VBA/VBA a function that doesn't return anything shouldn't have
parenthesis.
So a correct use in your case would be:
Function Demo()
Dim wd As New WebDriver
wd.Start "ie", "http://www.quackit.com"
wd.windowMaximize
wd.Open "/html/templates/frames/frames_example_1.html"
'To select the first frame:
wd.switchToFrame 0
'To click the first link:
wd.findElementByXPath("//a[0]").Click
' or:
wd.findElementByCssSelector("a:nth-child(0)").Click
' or:
wd.findElementsByTagName("a").Item(0).Click
' or:
Dim eles As WebElementCollection
Set eles = wd.findElementsByTagName("a")
eles(0).Click
End Function
Original comment by florentbr
on 8 Sep 2014 at 5:21
Thanks for the response.
The modified function provided is still returning the same error, "Specified
cast is not valid."
There is no difference when attempting the following.
wd.switchToFrame 0
wd.switchToFrame (0)
dim intFrame as integer
intFrame = 0
wd.switchToFrame intFrame
The frame is confirmed on the page and the index number is correct.
Any other suggestion?
Original comment by jospe...@gmail.com
on 9 Sep 2014 at 5:57
Looks like there is a bug with integers as index.
A workaround would be to provide a long instead (Ampersand at the end):
wd.switchToFrame 0&
Or to use the Selenium 1 command:
wd.selectFrame "index=0"
It should be fixed in the next release.
Original comment by florentbr
on 9 Sep 2014 at 11:17
Thank you for the work around.
The following worked successfully.
objWebDriver.switchToFrame 1&
and
Dim intIndex As Long
intIndex = 1
objWebDriver.switchToFrame intIndex
However, the Selenium 1 command did not.
objWebDriver.selectFrame "index = 1"
I will use the Long Cast until the next release.
Thanks again.
Original comment by jospe...@gmail.com
on 11 Sep 2014 at 3:12
Fixed in v1.0.20.0
Original comment by florentbr
on 18 Sep 2014 at 4:30
Original issue reported on code.google.com by
jospe...@gmail.com
on 6 Sep 2014 at 2:58Attachments: