I know this has been asked many times, and I've read many things that have been helpful, but I'm really having a tough time with select controls.
I finally read a post that said IE was different than FF and Chrome. That posting was helpful.
So I wrote 2 pieces of code. If IE, use ListItems in the Container that IE creates, and if the other browsers use Options in the Select control.
The problem I'm now having is that while this is working great for IE (ver 9) and FF (ver 14), Chrome (ver 20) is being difficult. Basically, in the section were I check it the Option I intend to click is visible or not, it always returns false (not visible) even though it is. Here's my code...
'This is part of a greater function that handles all types of controls. 'Many of the variables are defined at the top of this function, and so you will 'see them defined here. Hopefully it is clear. 'These first 5 lines find and click on the select control MySelectTag = Adapter.Create(Of Ranorex.SelectTag)(MyControl.Element) ControlsSession.mo_BrowserWebDoc.EnsureVisible() MySelectTag.EnsureVisible() MySelectTag.Click() MySelectTag.UseEnsureVisible = False ' This is important, or the control will jump around like crazy...and close itself while doing other things... 'BrowserType is my own ENUM of browser types 'ge_BrowserType is what keeps track of the browser I'm currently using If ge_BrowserType <> BrowserType.IE Then 'This code should work with FireFox and Chrome For Each MyOption In MySelectTag.Options MyOption.UseEnsureVisible = False 'sValue is what I passed into the function to find in the select control If MyOption.InnerText = sValue Then MySelectTag.PressKeys("{Home}") Ranorex.Delay.Milliseconds(250) 'This is where it fails for Chrome (but works for FireFox). MyOption is always NOT visible in Chrome, even though I have scrolled it into view (if it wasn't already) by pressing pagedown Do While Not MyOption.Visible MySelectTag.PressKeys("{PageDown}") Ranorex.Delay.Milliseconds(250) Loop MyOption.Click() bFound = True Exit For End If Next Else 'This code works with IE Dim c As Ranorex.Container = Nothing Dim l As Ranorex.ListItem = Nothing Dim u As Ranorex.Unknown = Nothing c = "/container[@caption='selectbox']" For Each u In c.Children If u.Element.PreferredCapability.Name.ToLower = "listitem" Then l = Adapter.Create(Of Ranorex.ListItem)(u.Element) 'sValue is what I passed into the function to find in the select control If l.Text = sValue Then MySelectTag.PressKeys("{Home}") Ranorex.Delay.Milliseconds(250) Do While Not l.Visible MySelectTag.PressKeys("{PageDown}") Ranorex.Delay.Milliseconds(250) Loop l.Click() bFound = True Exit For End If End If Next End IfAny thoughts?
Oh, and by the way, this code now means I no longer need to execute a script because when the click occurs, it fires the event, and if a message box appears it doesn't block me... see my previous post http://www.ranorex.com/forum/post14937. ... 5dc#p14937
Thanks,
Aracknid