我正在尝试运行并测试此代码,但缺少 selenium 并且我无法将其安装在我的系统中,在这种情况下我该怎么办?ERROR: while executetest.go:8:2: import "bitbucket.org/tebeka/selenium": cannot find packageINSTALL the package i tried:# apt-get install goisntallReading package lists... DoneBuilding dependency tree Reading state information... DoneE: Unable to locate package goisntall# apt-cache search goinstallgolang-src - Go programming language compiler - source filesCODE: testing/* Selenium example goinstall bitbucket.org/tebeka/selenium */package yahooimport ( "strings" "testing" "bitbucket.org/tebeka/selenium")func TestYahoo(t *testing.T) { /* We want firefox, don't care about version much */ caps := selenium.Capabilities { "browserName": "firefox", } wd, _ := selenium.NewRemote(caps, "", "") defer wd.Quit() /* Navigate to Yahoo */ wd.Get("http://www.yahoo.com") /* Fill the search box */ input, err := wd.FindElement(selenium.ByName, "p") if err != nil { t.Error(err.String()) } err = input.SendKeys("golang") if err != nil { t.Error(err.String()) } /* Hit the search button */ button, err := wd.FindElement(selenium.ById, "search-submit") if err != nil { t.Error(err.String()) } err = button.Click() if err != nil { t.Error(err.String()) } /* See that we get expected result */ source, err := wd.PageSource() if err != nil { t.Error(err.String()) } if !strings.Contains(source, "The Go Programming Language") { t.Error("Google can't find Go") }}
1 回答
- 1 回答
- 0 关注
- 400 浏览
添加回答
举报
0/150
提交
取消