MCPcopy Index your code
hub / github.com/tebeka/selenium / testFindElement

Function testFindElement

remote_test.go:995–1033  ·  view source on GitHub ↗
(t *testing.T, c config)

Source from the content-addressed store, hash-verified

993}
994
995func testFindElement(t *testing.T, c config) {
996 wd := newRemote(t, c)
997 defer quitRemote(t, wd)
998
999 if err := wd.Get(serverURL); err != nil {
1000 t.Fatalf("wd.Get(%q) returned error: %v", serverURL, err)
1001 }
1002
1003 for _, tc := range []struct {
1004 by, query string
1005 }{
1006 {ByName, "q"},
1007 {ByCSSSelector, "input[name=q]"},
1008 {ByXPATH, "/html/body/form/input[1]"},
1009 {ByLinkText, "тест"},
1010 } {
1011 elem, err := wd.FindElement(tc.by, tc.query)
1012 if err != nil {
1013 t.Errorf("wd.FindElement(%q, %q) returned error: %v", tc.by, tc.query, err)
1014 continue
1015 }
1016
1017 we, ok := elem.(*remoteWE)
1018 if !ok {
1019 t.Errorf("wd.FindElement(%q, %q) = %T, want a *remoteWE", tc.by, tc.query, elem)
1020 continue
1021 }
1022
1023 if len(we.id) == 0 {
1024 t.Errorf("wd.FindElement(%q, %q) returned an empty element", tc.by, tc.query)
1025 continue
1026 }
1027
1028 if we.parent != wd {
1029 t.Errorf("wd.FindElement(%q, %q) returned the wrong parent", tc.by, tc.query)
1030 continue
1031 }
1032 }
1033}
1034
1035func testFindElements(t *testing.T, c config) {
1036 wd := newRemote(t, c)

Callers

nothing calls this directly

Calls 4

newRemoteFunction · 0.85
quitRemoteFunction · 0.85
GetMethod · 0.65
FindElementMethod · 0.65

Tested by

no test coverage detected