Raconeisteron / selenium-vba

Automatically exported from code.google.com/p/selenium-vba
0 stars 1 forks source link

Select dropdown and click on Submit button #167

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Operating system : Windows 7
.Net Framework version :
Office Version : 2013
SeleniumWrapper version : SeleniumWrapperSetup-1.0.23.0.exe

What is your issue ?
I need to Open a webpage, select the dropdown and click on Submit button. After 
navigation to new page, download all the links available on it (Reports)

I am able to achieve all the requirements, except to select the dropdown before 
clicking on the Submit Button. Please help me.

URL: https://www.theice.com/marketdata/reports/166
Dropdown to select: 'M-Option on UK Natural Gas NBP Future'
Click: 'Submit' button

My code:
    selenium.Start "Chrome", ""
    selenium.setTimeout ("120000")
    selenium.setImplicitWait (5000)
    selenium.maximizeWindow

    selenium.Open "https://www.theice.com/marketdata/reports/166"
    selenium.setTimeout ("120000")
    selenium.setImplicitWait (5000)
    Application.Wait Now + TimeValue("00:00:10")

    selenium.findElementById("form-selectedContract").AsSelect.selectByValue "IFEU|M"
    selenium.Click ("name=submit")
    selenium.setTimeout ("120000")
    selenium.setImplicitWait (5000)

Thanks for your help.

Cheers,
Ravi.

Original issue reported on code.google.com by ravikira...@gmail.com on 1 Aug 2015 at 10:46

Attachments:

GoogleCodeExporter commented 9 years ago
This project has moved to GitHub:
http://florentbr.github.io/SeleniumBasic
This website and version is no longer be supported as Google has announced that 
it will shut down this service for good.

Now regarding your issue, the page contains a lot of background processing.
So the best way is to emulate exactly what the user would do:

    Dim driver As New ChromeDriver
    driver.Get "https://www.theice.com/marketdata/reports/166"

    Set form = driver.FindElementById("form_selectedContract_chosen")
    form.FindElementByTagName("a").Click
    form.FindElementByTagName("input").SendKeys "M-Option on UK Natural Gas NBP Future"
    form.FindElementByClassName("chosen-results").Click
    form.Submit

    Set elts = driver.FindElementsByCssSelector(".btn-link", 2, 10000)
    For Each e In elts
        e.Click
    Next

    driver.Wait 5000

    driver.Quit

Original comment by florentbr on 2 Aug 2015 at 11:32

GoogleCodeExporter commented 9 years ago

Original comment by florentbr on 2 Aug 2015 at 11:48

GoogleCodeExporter commented 9 years ago
Thanks a lot Florent. Exactly what I am looking at. I had banged by head over 
this for a day.

In the future, I'll get to github for any reference.

Thanks again,
Cheers,
Ravi.

Original comment by ravikira...@gmail.com on 3 Aug 2015 at 8:37