Minor code cleanup
This commit is contained in:
parent
117d42c3dd
commit
f683cfc4c1
|
@ -6,10 +6,6 @@ go:
|
|||
addons:
|
||||
apt:
|
||||
chrome: stable
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- libstdc++6
|
||||
before_install:
|
||||
- go get github.com/mattn/goveralls
|
||||
script:
|
||||
|
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016-2017 Kenneth Shaw
|
||||
Copyright (c) 2016-2018 Kenneth Shaw
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
26
nav_test.go
26
nav_test.go
|
@ -111,7 +111,7 @@ func TestNavigateToHistoryEntry(t *testing.T) {
|
|||
|
||||
var entries []*page.NavigationEntry
|
||||
var index int64
|
||||
err = c.Run(defaultContext, Navigate(testdataDir+"/"+"image.html"))
|
||||
err = c.Run(defaultContext, Navigate(testdataDir+"/image.html"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ func TestNavigateToHistoryEntry(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = c.Run(defaultContext, Navigate(testdataDir+"/"+"form.html"))
|
||||
err = c.Run(defaultContext, Navigate(testdataDir+"/form.html"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ func TestNavigateBack(t *testing.T) {
|
|||
c := testAllocate(t, "")
|
||||
defer c.Release()
|
||||
|
||||
err = c.Run(defaultContext, Navigate(testdataDir+"/"+"form.html"))
|
||||
err = c.Run(defaultContext, Navigate(testdataDir+"/form.html"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ func TestNavigateBack(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = c.Run(defaultContext, Navigate(testdataDir+"/"+"image.html"))
|
||||
err = c.Run(defaultContext, Navigate(testdataDir+"/image.html"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -200,14 +200,14 @@ func TestNavigateForward(t *testing.T) {
|
|||
c := testAllocate(t, "")
|
||||
defer c.Release()
|
||||
|
||||
err = c.Run(defaultContext, Navigate(testdataDir+"/"+"form.html"))
|
||||
err = c.Run(defaultContext, Navigate(testdataDir+"/form.html"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
|
||||
err = c.Run(defaultContext, Navigate(testdataDir+"/"+"image.html"))
|
||||
err = c.Run(defaultContext, Navigate(testdataDir+"/image.html"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ func TestStop(t *testing.T) {
|
|||
c := testAllocate(t, "")
|
||||
defer c.Release()
|
||||
|
||||
err = c.Run(defaultContext, Navigate(testdataDir+"/"+"form.html"))
|
||||
err = c.Run(defaultContext, Navigate(testdataDir+"/form.html"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ func TestReload(t *testing.T) {
|
|||
c := testAllocate(t, "")
|
||||
defer c.Release()
|
||||
|
||||
err = c.Run(defaultContext, Navigate(testdataDir+"/"+"form.html"))
|
||||
err = c.Run(defaultContext, Navigate(testdataDir+"/form.html"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ func TestCaptureScreenshot(t *testing.T) {
|
|||
c := testAllocate(t, "")
|
||||
defer c.Release()
|
||||
|
||||
err = c.Run(defaultContext, Navigate(testdataDir+"/"+"image.html"))
|
||||
err = c.Run(defaultContext, Navigate(testdataDir+"/image.html"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -342,7 +342,7 @@ func TestCaptureScreenshot(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = c.Run(defaultContext, Navigate(testdataDir+"/"+"form.html"))
|
||||
err = c.Run(defaultContext, Navigate(testdataDir+"/form.html"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ func TestRemoveOnLoadScript(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = c.Run(defaultContext, Navigate(testdataDir+"/"+"form.html"))
|
||||
err = c.Run(defaultContext, Navigate(testdataDir+"/form.html"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ func TestLocation(t *testing.T) {
|
|||
t.Parallel()
|
||||
|
||||
var err error
|
||||
expurl := testdataDir + "/" + "form.html"
|
||||
expurl := testdataDir + "/form.html"
|
||||
|
||||
c := testAllocate(t, "")
|
||||
defer c.Release()
|
||||
|
@ -409,7 +409,7 @@ func TestLocation(t *testing.T) {
|
|||
}
|
||||
|
||||
if urlstr != expurl {
|
||||
t.Fatalf("expected to be on form.html,got: %s", urlstr)
|
||||
t.Fatalf("expected to be on form.html, got: %s", urlstr)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
5
query.go
5
query.go
|
@ -11,11 +11,12 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/disintegration/imaging"
|
||||
|
||||
"github.com/chromedp/cdproto/cdp"
|
||||
"github.com/chromedp/cdproto/css"
|
||||
"github.com/chromedp/cdproto/dom"
|
||||
"github.com/chromedp/cdproto/page"
|
||||
"github.com/disintegration/imaging"
|
||||
)
|
||||
|
||||
// Nodes retrieves the document nodes matching the selector.
|
||||
|
@ -475,7 +476,7 @@ func Screenshot(sel interface{}, picbuf *[]byte, opts ...QueryOption) Action {
|
|||
return err
|
||||
}
|
||||
|
||||
// crop to box model contents.
|
||||
// crop to box model contents
|
||||
cropped := imaging.Crop(img, image.Rect(
|
||||
int(box.Margin[0])-pos[0], int(box.Margin[1])-pos[1],
|
||||
int(box.Margin[4])-pos[0], int(box.Margin[5])-pos[1],
|
||||
|
|
|
@ -805,7 +805,7 @@ func TestSubmit(t *testing.T) {
|
|||
t.Fatalf("got error: %v", err)
|
||||
}
|
||||
if title != "this is title" {
|
||||
t.Errorf("expected title to be 'chromedp - Google Search', got: '%s'", title)
|
||||
t.Errorf("expected title to be 'this is title', got: '%s'", title)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ func TestWaitReady(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("got error: %v", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestWaitVisible(t *testing.T) {
|
||||
|
@ -59,7 +58,6 @@ func TestWaitVisible(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("got error: %v", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestWaitNotVisible(t *testing.T) {
|
||||
|
@ -92,7 +90,6 @@ func TestWaitNotVisible(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("got error: %v", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestWaitEnabled(t *testing.T) {
|
||||
|
@ -141,7 +138,6 @@ func TestWaitEnabled(t *testing.T) {
|
|||
if value != "foo" {
|
||||
t.Fatalf("expected value to be foo, got: %s", value)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestWaitSelected(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user