第一次發(fā)現(xiàn)這種情況,驅(qū)動版本完全對的上,但是調(diào)用 chrome 就提示 Only local connections are allowed.
然后瀏覽器調(diào)用失敗報(bào)錯(cuò)。
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver s
afe.
ChromeDriver was started successfully.
解決方法:
調(diào)用 chrome 驅(qū)動的時(shí)候加個(gè)參數(shù) --whitelisted-ips=""
,值為空就是把所有調(diào)入來源都加入白名單。
ips 的全稱是 intrusion prevention system
,解釋為入侵防御系統(tǒng)。
C:\Selenium2.0\driver>chromedriver_70.0.3538.97_win32.exe --whitelisted-ips=""
Starting ChromeDriver 70.0.3538.97 (d035916fe243477005bc95fe2a5778b8f20b6ae1) on port 9515
All remote connections are allowed. Use a whitelist instead!
如果是封裝好的不能代碼里集成,可以外部 cmd 窗口里啟用驅(qū)動,后面加上這個(gè)參數(shù),注意參數(shù)前要有個(gè)空格,注意窗口不要關(guān),不然就失效了,可以保證啟用過程中可以正常的調(diào)用 chrome。
如果每次都這么做,可以創(chuàng)建個(gè)快捷方式,里面寫好參數(shù),這樣就每次執(zhí)行個(gè)快捷方式就完事了。
詳細(xì)報(bào)錯(cuò)內(nèi)容展示:
老版本和新版本的報(bào)錯(cuò)內(nèi)容存在一定差異。文章來源:http://www.zghlxwxcb.cn/news/detail-505913.html
Only local connections are allowed.
Exception in thread "AWT-EventQueue-0" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
System info: host: 'DESKTOP-1MPSR34', ip: '10.6.255.208', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_121'
Driver info: driver.version: SeleniumDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:622)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:141)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:174)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:163)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:152)
at com.yyuap.selenium.SeleniumDriver.initDriver(SeleniumDriver.java:195)
at com.yyuap.selenium.Debuger.init(Debuger.java:256)
at com.yyuap.selenium.Debuger.actionPerformed(Debuger.java:124)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6533)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6298)
at java.awt.Container.processEvent(Container.java:2236)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
at java.awt.Container.dispatchEventImpl(Container.java:2280)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.IllegalStateException: The process has not exited yet therefore no result is available ...
at org.apache.commons.exec.DefaultExecuteResultHandler.getException(DefaultExecuteResultHandler.java:76)
at org.openqa.selenium.os.UnixProcess.checkForError(UnixProcess.java:173)
at org.openqa.selenium.os.CommandLine.checkForError(CommandLine.java:185)
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:177)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:166)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
... 45 more
喜歡的點(diǎn)個(gè)贊?吧!文章來源地址http://www.zghlxwxcb.cn/news/detail-505913.html
到了這里,關(guān)于Selenium自動化chrome驅(qū)動版本匹配但是調(diào)用瀏覽器失敗:Only local connections are allowed. 問題解決的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!