Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions browsers/chromium-local.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"binary" : "%FILE:CHROMIUM%",
"args" : [
"--headless",
"--no-sandbox",
"--use-gl=swiftshader-webgl"
]
},
Expand Down
7 changes: 5 additions & 2 deletions go/metadata/capabilities/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,9 @@ func mergeLists(m1, m2 []interface{}) []interface{} {
return nl
}

// The mergeArgs function merges m1 and m2. For same argument exists in m1 and m2 and has
// prefix "--" or "-", the argument in m2 will override m1; If the same argument does not
// have prefix "--" or "-", then both same arguments in m1 and m2 will remain.
func mergeArgs(m1, m2 []interface{}) []interface{} {
m2Opts := map[string]bool{}

Expand All @@ -730,7 +733,7 @@ func mergeArgs(m1, m2 []interface{}) []interface{} {
m2Opts[arg[7:]] = true
continue // And leave arg out of m2Copy
}
if strings.HasPrefix(arg, "--") {
if strings.HasPrefix(arg, "-") {
tokens := strings.Split(arg, "=")
m2Opts[tokens[0]] = true
}
Expand All @@ -742,7 +745,7 @@ func mergeArgs(m1, m2 []interface{}) []interface{} {

for _, a := range m1 {
if arg, ok := a.(string); ok {
if strings.HasPrefix(arg, "--") {
if strings.HasPrefix(arg, "-") {
tokens := strings.Split(arg, "=")
// Skip options from m1 that are redefined in m2
if m2Opts[tokens[0]] {
Expand Down
29 changes: 27 additions & 2 deletions go/metadata/capabilities/capabilities_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ func TestMerge(t *testing.T) {
"an option",
"--anOption",
"--anOption=true",
"-anotherOption",
map[string]interface{}{
"some": "map",
},
Expand All @@ -450,7 +449,7 @@ func TestMerge(t *testing.T) {
},
},
{
name: "args -- redefines",
name: "overrides '--' prefixed args",
input1: map[string]interface{}{
"args": []interface{}{
"an option",
Expand Down Expand Up @@ -531,6 +530,31 @@ func TestMerge(t *testing.T) {
},
},
},
{
name: "overrides '-' prefixed args",
input1: map[string]interface{}{
"args": []interface{}{
"option",
"--anOption",
"-width=1024",
},
},
input2: map[string]interface{}{
"args": []interface{}{
"option",
"--anOption",
"-width=2048",
},
},
result: map[string]interface{}{
"args": []interface{}{
"option",
"option",
"--anOption",
"-width=2048",
},
},
},
{
name: "chromeOptions to goog:chromeOptions",
input1: map[string]interface{}{
Expand Down Expand Up @@ -1600,3 +1624,4 @@ func TestMergeUnder(t *testing.T) {
})
}
}

21 changes: 21 additions & 0 deletions go/webdriver/webdriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ type WebDriver interface {
Screenshot(context.Context) (image.Image, error)
// ElementScreenshot takes a screenshot of the visible region encompassed by the bounding rectangle of element.
ElementScreenshot(ctx context.Context, el WebElement) (image.Image, error)
// ElementGetText gets the text of an element.
ElementGetText(ctx context.Context, el WebElement) (string, error)
// ElementSendKeys sends keys to the element.
ElementSendKeys(ctx context.Context, el WebElement, keys string) error
// WindowHandles returns a slice of the current window handles.
WindowHandles(context.Context) ([]string, error)
// CurrentWindowHandle returns the handle of the active window.
Expand Down Expand Up @@ -393,6 +397,23 @@ func (d *webDriver) ElementScreenshot(ctx context.Context, el WebElement) (image
return png.Decode(base64.NewDecoder(base64.StdEncoding, strings.NewReader(value)))
}

// ElementGetText gets the text of an element.
func (d *webDriver) ElementGetText(ctx context.Context, el WebElement) (string, error) {
var value string
if err := d.get(ctx, fmt.Sprintf("element/%s/text", el.ID()), &value); err != nil {
return "", err
}
return value, nil
}

// ElementSendKeys sends keys to an element.
func (d *webDriver) ElementSendKeys(ctx context.Context, el WebElement, keys string) error {
if err := d.post(ctx, fmt.Sprintf("element/%s/value", el.ID()), map[string]string{"text": keys}, nil); err != nil {
return err
}
return nil
}

// WindowHandles returns a slice of the current window handles.
func (d *webDriver) WindowHandles(ctx context.Context) ([]string, error) {
var value []string
Expand Down
4 changes: 2 additions & 2 deletions go/wsl/hub/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (h *Hub) newSessionFromCaps(ctx context.Context, caps *capabilities.Capabil
if err := resolver.RecyclePorts(); err != nil {
log.Printf("Error recycling ports: %v", err)
}
return "", nil, err
return "", nil, fmt.Errorf("Error launching driver binary: %w", err)
}

s, err := d.NewSession(ctx, caps, w)
Expand All @@ -165,7 +165,7 @@ func (h *Hub) newSessionFromCaps(ctx context.Context, caps *capabilities.Capabil
if err := d.Shutdown(ctx); err != nil {
log.Printf("Error shutting down driver: %v", err)
}
return "", nil, err
return "", nil, fmt.Errorf("Error requesting new session: %w", err)
}

return s, d, nil
Expand Down
7 changes: 5 additions & 2 deletions testing/web/debugger/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
# limitations under the License.
"""Web Test Launcher Debugger Front-End."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import code
import getpass
import hashlib
import json
import socket
import sys
import urllib
from six.moves import urllib


class Debugger:
Expand Down Expand Up @@ -135,7 +138,7 @@ def delete_breakpoint(self, breakpoint_id):

def collect_analytics():
try:
urllib.urlopen(
urllib.request.urlopen(
"http://www.google-analytics.com/collect?v=1&aip=1&tid=UA-52159295-3"
"&t=screenview&cd=start&an=WTL+Debugger&uid=" +
hashlib.md5(getpass.getuser()).hexdigest()).close
Expand Down
29 changes: 14 additions & 15 deletions web/versioned/browsers-0.3.2.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -56,40 +56,39 @@ def org_chromium_chromedriver():
name = "org_chromium_chromedriver",
licenses = ["reciprocal"], # BSD 3-clause, ICU, MPL 1.1, libpng (BSD/MIT-like), Academic Free License v. 2.0, BSD 2-clause, MIT
amd64_sha256 =
"0ead02145854b60a3317b59031205b362fb4cfdb680fef20e95c89582e6e38be",
"f6b9852031d185739a2c1816508fe8158eb92782d13e831b8345957ef2506fe8",
amd64_urls = [
"https://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64/664981/chromedriver_linux64.zip",
"https://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64/768968/chromedriver_linux64.zip",
],
macos_sha256 =
"8dd159e27b13b16262afa6993b15321e736c3b484da363c0e03bb050d72522c9",
"aa0124085146556d5d32ad172670e5dcef79b7429380112ad02898047ba7a8b7",
macos_urls = [
"https://commondatastorage.googleapis.com/chromium-browser-snapshots/Mac/665002/chromedriver_mac64.zip",
"https://commondatastorage.googleapis.com/chromium-browser-snapshots/Mac/768968/chromedriver_mac64.zip",
],
windows_sha256 =
"1cc881364974102182257a5c5c2b9cfed513689dee28924ca44df082bdf9fd60",
"cb19c5b53efc65be6f79421df0c9a226603b09cc959bc47991552c8820516588",
windows_urls = [
"https://commondatastorage.googleapis.com/chromium-browser-snapshots/Win/664999/chromedriver_win32.zip",
"https://commondatastorage.googleapis.com/chromium-browser-snapshots/Win/776896/chromedriver_win32.zip",
],
)

def org_chromium_chromium():
platform_http_file(
name = "org_chromium_chromium",
licenses = ["notice"], # BSD 3-clause (maybe more?)
amd64_sha256 =
"b1e30c4dec8a451f8fe10d1f2d3c71e491d0333425f32247fe5c80a0a354303d",
"0e303931d9c3e065a160f5d31f1178c647f0748fb0b58b1945b84b04fe1c1165",
amd64_urls = [
"https://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64/664981/chrome-linux.zip",
"https://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64/768968/chrome-linux.zip",
],
macos_sha256 =
"7c0ba93616f44a421330b1c1262e8899fbdf7916bed8b04c775e0426f6f35ec6",
"39118c96db1b3fdb0129f434912a329c5ca07d3a1c6c6cda673d3383d83e2f9a",
macos_urls = [
"https://commondatastorage.googleapis.com/chromium-browser-snapshots/Mac/665002/chrome-mac.zip",
"https://commondatastorage.googleapis.com/chromium-browser-snapshots/Mac/768968/chrome-mac.zip",
],
windows_sha256 =
"f2facd0066270078d0e8999e684595274c359cac3946299a1ceedba2a5de1c63",
"08c6b7ec05cd8f172c2fe9d29ce26e3af9fdf4d04f76b5dd53d0236df0396377",
windows_urls = [
"https://commondatastorage.googleapis.com/chromium-browser-snapshots/Win/664999/chrome-win.zip",
"https://commondatastorage.googleapis.com/chromium-browser-snapshots/Win/776896/chrome-win.zip",
],
)

Expand Down Expand Up @@ -119,8 +118,8 @@ def org_mozilla_geckodriver():
"https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz",
],
macos_sha256 =
"6553195cd6f449e2b90b0bdfe174c6c3337ed571ac6d57a0db028ac5f306cca9",
"4739ef8f8af5d89bd4a8015788b4dc45c2f5f16b2fdc001254c9a92fe7261947",
macos_urls = [
"https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-macos.tar.gz",
"https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-macos.tar.gz",
],
)