package sharelatex import ( "fmt" "math/rand" "net/http" "os" "path/filepath" "time" "github.com/tebeka/selenium" ) func IntegrationTest(url string) error { _, err := http.Get(url) if err != nil { fmt.Printf("failed to get '%s': %s", url, err) } caps := selenium.Capabilities{"browserName": "firefox"} wd, err := selenium.NewRemote(caps, "") if err != nil { return err } defer wd.Quit() // Get simple playground interface wd.Get(url) e, _ := wd.FindElement(selenium.ByXPATH, "//input[@type='email']") e.Clear() e.SendKeys("joerg@higgsboson.tk") e, _ = wd.FindElement(selenium.ByXPATH, "//input[@type='password']") e.Clear() e.SendKeys("password") e, _ = wd.FindElement(selenium.ByXPATH, "//button[@type='submit']") e.Click() for { _, err = wd.FindElement(selenium.ByLinkText, "Account") if err == nil { break } time.Sleep(time.Millisecond * 100) } time.Sleep(time.Millisecond * 4000) e, _ = wd.FindElement(selenium.ByLinkText, "New Project") e.Click() e, _ = wd.FindElement(selenium.ByLinkText, "Blank Project") e.Click() e, _ = wd.FindElement(selenium.ByXPATH, "//input[@type='text']") e.Clear() e.SendKeys(fmt.Sprintf("p %d", rand.Int63())) e, _ = wd.FindElement(selenium.ByCSSSelector, "button.btn-primary") // Create e.Click() time.Sleep(time.Millisecond * 3000) e, _ = wd.FindElement(selenium.ByCSSSelector, `i.fa-comment`) e.Click() e, _ = wd.FindElement(selenium.ByCSSSelector, `div.new-message textarea`) e.SendKeys("hello world" + selenium.EnterKey) e, _ = wd.FindElement(selenium.ByCSSSelector, "i.fa.fa-upload") // Upload e.Click() e, _ = wd.FindElement(selenium.ByName, "file") // Create dir, err := filepath.Abs(filepath.Dir(os.Args[0])) e.SendKeys(filepath.Join(dir, "./test.txt")) time.Sleep(time.Millisecond * 500) e, _ = wd.FindElement(selenium.ByCSSSelector, "textarea") // Latex Doc e.Clear() e.SendKeys(`\documentclass{article} \begin{document} ello \end{document}`) time.Sleep(time.Millisecond * 1000) return nil }