Link to home
Start Free TrialLog in
Avatar of Bruj
BrujFlag for United States of America

asked on

Looking for way to select a dropdown option with selenium wrapper in VBA

I have the following html that I want to select "Orders"
<select id="saved_queries" onchange="change_qb_export_filetype();ProcessFieldUsage(this)" name="QB_ID">
                    <option value="8" data-filetype=""></option>
<option value="3" data-filetype="CSV">AllCategories</option>
<option value="4" data-filetype="CSV">AllCustExport</option>
<option value="7" data-filetype="CSV">MasterProductExport</option>
<option value="10" data-filetype="CSV">OrderDetails</option>
<option value="9" data-filetype="CSV">Orders</option>
<option value="6" data-filetype="CSV">ProductEx1</option>
</select>

Open in new window


When I run the firebug from Firefox, it gives me the following when I record the macro
 ' ERROR: Caught exception [TypeError: value.replace is not a function]

How would I select option "Orders" value 9 using selenium wrapper?
ASKER CERTIFIED SOLUTION
Avatar of Thommy
Thommy
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bruj

ASKER

When I try, either one, I do get an error."No such element"
I have used "selector", I have tried the ID and the name.

Public Sub untitled()
  Dim driver As New SeleniumWrapper.WebDriver
  Dim By As New By, Assert As New Assert, Verify As New Verify, Waiter As New Waiter
  driver.addArgument "test-type"
  driver.Start "chrome", "http://www.timberturners.com/"
  driver.setImplicitWait 5000

  driver.get "/login.asp"

  driver.findElementByName("email").Clear
  driver.findElementByName("email").SendKeys "sales@timberturners.com"
  driver.findElementByName("password").Clear
  driver.findElementByName("password").SendKeys "password"
  driver.findElementByName("imageField2").Click
  
 ' driver.findElementById("Inventory_ImportExport").Click
driver.get "/admin/db_export.asp?QueryBank=Y"
 ' driver.findElementByLinkText("Saved Exports").Click
 ' driver.findElementByLinkText("Standard Export").Click
  ' ERROR: Caught exception [TypeError: value.replace is not a function]
  'driver.findElementByLinkText("Export").Click
  'driver.findElementById("btnSaveChanges").Click
  'driver.findElementByCssSelector("span.v13-icon-download-primary").Click
'  driver.findElementByCssSelector("saved_queries").AsSelect.selectByValue "9"
  
  '.AsSelect.selectByText "Orders"
   driver.findElementByCssSelector("saved_queries").AsSelect.selectByText "Orders"
  driver.Select "css=selector", "label=Orders"
  'QB_ID
    driver.findElementByCssSelector("QB_ID").AsSelect.selectByText "Orders"

  ' ERROR: Caught exception [TypeError: value.replace is not a function]
 ' driver.findElementByLinkText("Export").Click
 ' driver.findElementById("btnSaveChanges").Click
  driver.findElementByLinkText("Download").Click
  driver.findElementByLinkText("Log out").Click
  driver.findElementByName("password").Clear
  driver.findElementByName("password").SendKeys "password"
  
  driver.stop
End Sub

Open in new window



Thanks!
Avatar of Bruj

ASKER

I tried to use the macro recorder for VBA remote, and it gave me a workable code!
Here is what is working:

  driver.Select "id=saved_queries", "label=Orders"

I hope this helps somebody else!

Cheers and Thanks