sclevine / agouti

A WebDriver client and acceptance testing library for Go
MIT License
821 stars 105 forks source link

how to add options like a different pot to agouti.Selenium() #131

Closed marcelloh closed 7 years ago

marcelloh commented 7 years ago

Can you give an example in how this should work? I did try to figure out fro the documentation, but get lost every time :-(

I see that I can use agouti.Selenium(options) but unclear to me is how those options are, and I think a more complete example would be nice

sclevine commented 7 years ago

Hi @marcelloh,

Are you asking how to run Selenium on a custom port, or are you asking how to connect to an already running instance of Selenium?

marcelloh commented 7 years ago

I have no idea what agouti.Selenium(options) does. If it connects to an already running Selenium, then explain what the options can do. If it starts a selenium instance somehow, then... explain what the options can do. If both is possible, then... explain what the options can do.

sclevine commented 7 years ago

Agouti is documented here and at agouti.org.

agouti.Selenium() starts an instance of Selenium WebDriver automatically. Options are listed here, but do not include an option for changing the randomized port.

If you want to configure Agouti to start Selenium on a custom port automatically, you can use agouti.NewWebDriver, documented in detail here. See the implementation for agouti.Selenium as an additional example.

If you already have an instance of Selenium running, you can use agouti.NewPage() to connect to it. Just provide a URL to the webdriver.

marcelloh commented 7 years ago

I found out that with the following:

    var agoutiDriver *agouti.WebDriver
    //agoutiDriver = agouti.PhantomJS()
    //agoutiDriver = agouti.Selenium()
    agoutiDriver = agouti.ChromeDriver()
    if err := agoutiDriver.Start(); err != nil {
        panic(err)
        //t.Fatal("Failed to start Chrome:", err)
    }

I could actually see what was wrong. panic: failed to start service: failed to run command: exec: "chromedriver.exe": executable file not found in %PATH% where the

t.Fatal("Failed to start Chrome:", err)

gives me: panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x0 pc=0x7495ae] which makes the error handling a bit useless for a human :-(

sclevine commented 7 years ago

This is the expected behavior of the standard library testing.T.Fatal() method -- you can't pass it a nil interface value. The behavior is not related to Agouti.

It appears that you're running Windows and don't have ChromeDriver installed. Is this the case?

marcelloh commented 7 years ago

yes, a panic(err) did tell me this :-(