(t *testing.T, c config)
| 1095 | } |
| 1096 | |
| 1097 | func testClick(t *testing.T, c config) { |
| 1098 | wd := newRemote(t, c) |
| 1099 | defer quitRemote(t, wd) |
| 1100 | |
| 1101 | if err := wd.Get(serverURL); err != nil { |
| 1102 | t.Fatalf("wd.Get(%q) returned error: %v", serverURL, err) |
| 1103 | } |
| 1104 | const searchBoxName = "q" |
| 1105 | input, err := wd.FindElement(ByName, searchBoxName) |
| 1106 | if err != nil { |
| 1107 | t.Fatalf("wd.FindElement(%q, %q) returned error: %v", ByName, searchBoxName, err) |
| 1108 | } |
| 1109 | const query = "golang" |
| 1110 | if err = input.SendKeys(query); err != nil { |
| 1111 | t.Fatalf("input.SendKeys(%q) returned error: %v", query, err) |
| 1112 | } |
| 1113 | |
| 1114 | const selectTag = "select" |
| 1115 | sel, err := wd.FindElement(ByCSSSelector, selectTag) |
| 1116 | if err != nil { |
| 1117 | t.Fatalf("wd.FindElement(%q, %q) returned error: %v", ByCSSSelector, selectTag, err) |
| 1118 | } |
| 1119 | if err = sel.Click(); err != nil { |
| 1120 | t.Fatalf("input.Click() returned error: %v", err) |
| 1121 | } |
| 1122 | time.Sleep(2 * time.Second) |
| 1123 | option, err := sel.FindElement(ByID, "secondValue") |
| 1124 | if err != nil { |
| 1125 | t.Fatalf("input.FindElement(%q, %q) returned error: %v", ByID, "secondValue", err) |
| 1126 | } |
| 1127 | if err = option.Click(); err != nil { |
| 1128 | t.Fatalf("option.Click() returned error: %v", err) |
| 1129 | } |
| 1130 | if c.browser == "firefox" { |
| 1131 | // Click anywhere else to de-focus the drop-down menu. |
| 1132 | if err = input.Click(); err != nil { |
| 1133 | t.Fatalf("wd.Click() returned error: %v", err) |
| 1134 | } |
| 1135 | } |
| 1136 | |
| 1137 | const buttonID = "submit" |
| 1138 | button, err := wd.FindElement(ByID, buttonID) |
| 1139 | if err != nil { |
| 1140 | t.Fatalf("wd.FindElement(%q, %q) returned error: %v", ByID, buttonID, err) |
| 1141 | } |
| 1142 | if err := wd.SetPageLoadTimeout(2 * time.Second); err != nil { |
| 1143 | t.Fatalf("wd.SetImplicitWaitTimeout() returned error: %v", err) |
| 1144 | } |
| 1145 | if err = button.Click(); err != nil { |
| 1146 | t.Fatalf("wd.Click() returned error: %v", err) |
| 1147 | } |
| 1148 | |
| 1149 | // The page load timeout for Firefox and Selenium 3 seems to not work for |
| 1150 | // clicking form buttons. Sleep a bit to reduce impact of a flaky test. |
| 1151 | if c.browser == "firefox" && c.seleniumVersion.Major == 3 { |
| 1152 | time.Sleep(2 * time.Second) |
| 1153 | } |
| 1154 | source, err := wd.PageSource() |
nothing calls this directly
no test coverage detected