(t *testing.T, c config)
| 1467 | } |
| 1468 | |
| 1469 | func testLog(t *testing.T, c config) { |
| 1470 | switch { |
| 1471 | case c.browser == "htmlunit": |
| 1472 | t.Skip("Skipping on htmlunit") |
| 1473 | case c.browser == "firefox" && (c.seleniumVersion.Major == 3 || c.seleniumVersion.Major == 0): |
| 1474 | // Log is not supported on Firefox with Selenium 3. |
| 1475 | // https://github.com/w3c/webdriver/issues/406 |
| 1476 | // https://github.com/mozilla/geckodriver/issues/284 |
| 1477 | t.Skip("The log interface is not supported on Firefox, since it is not yet part of the W3C spec.") |
| 1478 | } |
| 1479 | caps := newTestCapabilities(t, c) |
| 1480 | caps.SetLogLevel(log.Browser, log.All) |
| 1481 | if c.browser == "chrome" { |
| 1482 | caps.SetLogLevel(log.Performance, log.All) |
| 1483 | } |
| 1484 | |
| 1485 | wd := &remoteWD{ |
| 1486 | capabilities: caps, |
| 1487 | urlPrefix: c.addr, |
| 1488 | } |
| 1489 | if _, err := wd.NewSession(); err != nil { |
| 1490 | t.Fatalf("wd.NewSession() returned error: %v", err) |
| 1491 | } |
| 1492 | defer quitRemote(t, wd) |
| 1493 | |
| 1494 | url := serverURL + "/log" |
| 1495 | if err := wd.Get(url); err != nil { |
| 1496 | t.Fatalf("wd.Get(%q) returned error: %v", url, err) |
| 1497 | } |
| 1498 | logs, err := wd.Log(log.Browser) |
| 1499 | if err != nil { |
| 1500 | t.Fatalf("wd.Log(Browser) returned error: %v", err) |
| 1501 | } |
| 1502 | if len(logs) == 0 { |
| 1503 | t.Fatalf("empty reply from wd.Log(Browser)") |
| 1504 | } else { |
| 1505 | for _, l := range logs { |
| 1506 | if len(l.Level) == 0 || l.Timestamp.Unix() == 0 || len(l.Message) == 0 { |
| 1507 | t.Errorf("wd.Log(Browser) returned malformed message: %+v", l) |
| 1508 | } |
| 1509 | } |
| 1510 | } |
| 1511 | |
| 1512 | if c.browser == "chrome" { |
| 1513 | logs, err = wd.Log(log.Performance) |
| 1514 | if err != nil { |
| 1515 | t.Fatalf("wd.Log(Performance) returned error: %v", err) |
| 1516 | } |
| 1517 | if len(logs) == 0 { |
| 1518 | t.Fatal("empty reply from wd.Log(Performance)") |
| 1519 | } else { |
| 1520 | for _, l := range logs { |
| 1521 | if len(l.Level) == 0 || l.Timestamp.Unix() == 0 || len(l.Message) == 0 { |
| 1522 | t.Errorf("wd.Log(Browser) returned malformed message: %+v", l) |
| 1523 | } |
| 1524 | // Make sure the timestamp conversion is vaguely correct. In |
| 1525 | // practice, this difference should be in the milliseconds range. |
| 1526 | if time.Now().Sub(l.Timestamp) > time.Hour { |
nothing calls this directly
no test coverage detected