Tag Archives: Chromedriver

Mac environment and python + selenium environment are built to solve the error reporting problem of chromedriver

####

Create a new Python virtual environment and install selenium

Create a new Python project,

####

from selenium import webdriver

driver = webdriver.Chrome()

driver.get("https://www.baidu.com")

###

report errors:

‘chromedriver’ executable needs to be in PAT

###

What should I do?

Download chromedriver

Step 1: check your browser version and enter the URL: chrome://version/

Step 2: download the corresponding version of chromedrive at: http://chromedriver.storage.googleapis.com/index.html

Step 3: put the package under the project directory,

Step 4: modify the code and add the file path of drive,

Here is the code:

###

from selenium import webdriver

driver = webdriver.Chrome(executable_path="./chromedriver")

driver.get("https://www.baidu.com")

###

Then you can play happily. As long as you master the positioning and various operation APIs, you can basically get started and do your own projects,

 

###

 

 

 

 

####

Solve the chrome driver error original error: Chrome not reachable

The error information is as follows:

error: Chromedriver: Chromedriver exited unexpectedly with code null, signal SIG
TERM
info: Chromedriver: Changed state to 'stopped'
warn: Chromedriver for context WEBVIEW_com.tencent.mm:tools stopped unexpectedly

warn: Chromedriver quit unexpectedly, but it wasn't the active context, ignoring

error: Chromedriver: Error: An error occurred (Original error: chrome not reacha
ble
  (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a9468
2a),platform=Windows NT 6.1 x86_64))
    at JWProxy.command$ (lib/proxy.js:133:15)
    at tryCatch (D:\Program Files\Appium\node_modules\appium\node_modules\appium
-chromedriver\node_modules\appium-jsonwp-proxy\node_modules\babel-runtime\regene
rator\runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (D:\Program Files\Appium\n
ode_modules\appium\node_modules\appium-chromedriver\node_modules\appium-jsonwp-p
roxy\node_modules\babel-runtime\regenerator\runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (D:\P
rogram Files\Appium\node_modules\appium\node_modules\appium-chromedriver\node_mo
dules\appium-jsonwp-proxy\node_modules\babel-runtime\regenerator\runtime.js:100:
21)
    at GeneratorFunctionPrototype.invoke (D:\Program Files\Appium\node_modules\a
ppium\node_modules\appium-chromedriver\node_modules\appium-jsonwp-proxy\node_mod
ules\babel-runtime\regenerator\runtime.js:136:37)
    at bound (domain.js:287:14)
    at GeneratorFunctionPrototype.runBound (domain.js:300:12)
    at run (D:\Program Files\Appium\node_modules\appium\node_modules\appium-chro
medriver\node_modules\appium-jsonwp-proxy\node_modules\babel-runtime\node_module
s\core-js\library\modules\es6.promise.js:89:39)
    at D:\Program Files\Appium\node_modules\appium\node_modules\appium-chromedri
ver\node_modules\appium-jsonwp-proxy\node_modules\babel-runtime\node_modules\cor
e-js\library\modules\es6.promise.js:100:28
    at flush (D:\Program Files\Appium\node_modules\appium\node_modules\appium-ch
romedriver\node_modules\appium-jsonwp-proxy\node_modules\babel-runtime\node_modu
les\core-js\library\modules\$.microtask.js:17:13)
    at nextTickCallbackWith0Args (node.js:420:9)
    at process._tickDomainCallback (node.js:390:13)
 { [Error: An error occurred (Original error: chrome not reachable
  (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a9468
2a),platform=Windows NT 6.1 x86_64))]
  status: 100,
  value: { message: 'chrome not reachable\n  (Driver info: chromedriver=2.18.343
845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a),platform=Windows NT 6.1 x86_64)'
},
  httpCode: 200 }

 

  

Solution: modify the files in the appium installation directory, for example:

D:\Program Files\Appium\node_modules\appium\lib\devices\android\android-hybrid.js

Find the androidhybrid.startchromedriverproxy function and comment out the relevant contents

 

 

Cause of problem:

When appium switches to the HTML page for the first time, a new chrome driver will be generated; When switching to HTML for the second time, the existing chrome driver will be used. But in fact, every time we open an activity in our application, we usually re create a webchromeclient, so here we change it to generate a new chromedriver anyway

 

Reference to the original text: http://laocaixw.github.io/2016/11/01/Appium When testing Android hybrid applications, the positioning problem when switching to WebView for the second time /?UTM_source=tuicool& utm_medium=referral