Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #162 from vania-pooh/master
Browse files Browse the repository at this point in the history
Supporting latest Chrome versions in devtools
  • Loading branch information
vania-pooh authored Jun 20, 2019
2 parents 8cb4e30 + 369fc38 commit c7551fa
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions selenium/chrome/devtools/devtools.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,31 +118,36 @@ func getPageWebSocketUrl(targetId string) (*url.URL, error) {
}

func detectDevtoolsHost(baseDir string) string {
candidates, err := filepath.Glob(filepath.Join(baseDir, ".org.chromium.Chromium*"))
if err == nil {
for _, c := range candidates {
f, err := os.Stat(c)
if err != nil {
continue
}
if !f.IsDir() {
continue
}
portFile := filepath.Join(c, "DevToolsActivePort")
data, err := ioutil.ReadFile(portFile)
if err != nil {
continue
}
lines := strings.Split(string(data), "\n")
if len(lines) == 0 {
continue
}
port, err := strconv.Atoi(lines[0])
if err != nil {
continue
}
return fmt.Sprintf("127.0.0.1:%d", port)
var candidates []string
for _, glob := range []string{".com.google.Chrome*", ".org.chromium.Chromium*"} {
cds, err := filepath.Glob(filepath.Join(baseDir, glob))
if err == nil {
candidates = append(candidates, cds...)
}

}
for _, c := range candidates {
f, err := os.Stat(c)
if err != nil {
continue
}
if !f.IsDir() {
continue
}
portFile := filepath.Join(c, "DevToolsActivePort")
data, err := ioutil.ReadFile(portFile)
if err != nil {
continue
}
lines := strings.Split(string(data), "\n")
if len(lines) == 0 {
continue
}
port, err := strconv.Atoi(lines[0])
if err != nil {
continue
}
return fmt.Sprintf("127.0.0.1:%d", port)
}
return devtoolsHost
}

0 comments on commit c7551fa

Please sign in to comment.