会话未创建,未处理的检查器错误

时间:2019-03-28 12:49:48

标签: webdriver selenium-chromedriver codeceptjs

我正在尝试从笔记本电脑通过chromedriver.exe(chromedriver = 72.0.3626.69)连接到机顶盒,但无法这样做。我的机顶盒启用了铬和webdriver。我们曾经通过机顶盒(无头chrome)上的selenium python / selenium java远程Web驱动程序库运行测试脚本-可以在电视上轻松看到频道浏览,电视指南的打开等。前提条件是机顶盒必须在连接了以太网电缆的情况下启用webdriver,以便获取IP地址。

当前,我们想通过codeceptjs / webdriver库复制相同的结构,但我不能这样做。

以下是我尝试过的配置:

1)codecept.conf.js文件

exports.config = {
   tests: './*_test.js',
   output: './output',
   helpers: {

     WebDriver: {
       url: 'http://locahost',
       port: 9515,     
       smartWait: 30000,  
       waitForTimeout: 15000,
       keepBrowserState: true,
       restart: false,
       browser: 'chrome',      
       desiredCapabilities:{      
         chromeOptions: {
           args : ["--disable-gpu","--allow-file-access-from-files", "--disable-web-security", "--ignore-certificate-errors" ],
           debuggerAddress: "10.12.130.83:2999",  /* this is the ip address of set top box */


         }, 

       }
     },
    MyHelper:{
      require: "./codecept_anupam.js"
    }  
   }
}

2)codecept_anupam.js

const Helper = codecept_helper;
const event = require('codeceptjs').event;

class MyHelper extends Helper {
 constructor () {
    super();
  }

_beforeSuite  (suite) {
    console.log('_beforeSuite');
    this.suiteTitle = suite.title;
    console.log(this.helpers);
    console.log(this.helpers['WebDriver']);
    if (!this.target)
    {
        //this.target = this.helpers['Puppeteer'];
        this.target = this.helpers['WebDriver'];
        this.page = this.target.browser;
        //this.page.send('Security.setIgnoreCertificateErrors', { ignore: 
    true });
    }
    //return 


   this.target.amOnPage('file:///C:/development/Codefest/app/client/launch-emulator.html');
      //return this.target.amOnPage('http://10.12.130.83:2999/Main.html? 
  page=1');
    }
}

module.exports = MyHelper;
;

我确保Selenium服务器已启动并通过chromedriver运行。我已经使用了以下命令。

java -Dwebdriver.chrome.driver=chromedriver.exe -jar selenium-server-standalone-3.141.59.jar -port 9515

以下是错误消息:-

[Session] Starting singleton browser session
[1] Error | Error: Can't connect to WebDriver.
session not created: session not created
from unknown error: unhandled inspector error: {"code":-32601,"data": 
[{"code":-32601,"message":"'Target' domain was not 
found"}],"message":"'Target' domain was not found"}
(Session info: =)
(Driver info: chromedriver=72.0.3626.69 
(3c16f8a135abc0d4da2dff33804db79b849a7c38),platform=Windows NT 10.0.14393 x86_64) (WARNING: The server did not provide any stacktrace information)
 Command duration or timeout: 115 milliseconds
 Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11- 
 14T08:25:53'


    System info: host: 'MOB700042', ip: '169.254.47.0', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_101'
Driver info: driver.version: unknown

Please make sure Selenium Server (ChromeDriver or PhantomJS) is running and accessible
    Emitted | test.failed ([object Object])
  × "before all" hook: codeceptjs.beforeSuite in 2079ms
    [1] Error | Error: Can't connect to WebDriver.
session not created: session not created
from unknown error: unhandled inspector error: {"code":-32601,"data":[{"code":-32601,"message":"'Target' domain was not found"}],"message":"'Target' domain was not found"}
  (Session info: =)
  (Driver info: chromedriver=72.0.3626.69 (3c16f8a135abc0d4da2dff33804db79b849a7c38),platform=Windows NT 10.0.14393 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 115 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'MOB700042', ip: '169.254.47.0', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_101'
Driver info: driver.version: unknown

Please make sure Selenium Server (ChromeDriver or PhantomJS) is running and accessible
Error: Can't connect to WebDriver.
session not created: session not created
from unknown error: unhandled inspector error: {"code":-32601,"data":[{"code":-32601,"message":"'Target' domain was not found"}],"message":"'Target' domain was not found"}
  (Session info: =)
  (Driver info: chromedriver=72.0.3626.69 (3c16f8a135abc0d4da2dff33804db79b849a7c38),platform=Windows NT 10.0.14393 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 115 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'MOB700042', ip: '169.254.47.0', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_101'
Driver info: driver.version: unknown

Please make sure Selenium Server (ChromeDriver or PhantomJS) is running and accessible

我们在python驱动程序中使用以下代码通过chromedriver连接到机顶盒,对我们来说效果很好:

def start(self): 
    if self.running is False:
        #kill any old process        
        str_command = "taskkill /f /t /im chromedriver.exe"
        tmp_process = subprocess.Popen(str_command.strip(), shell=True)
        tmp_process.wait()

        str_command = "_driver\\chromedriver.exe --port=9515 --whitelisted-ips" # --verbose
        self.process = subprocess.Popen(str_command.strip(), shell=True)

        time.sleep(6)
        options = ChromeOptions()
        options.add_experimental_option("debuggerAddress", self.stb_ip)
        self.driver = webdriver.Remote(command_executor='http://localhost:9515', desired_capabilities = options.to_capabilities())

        self.running = True      
    return

0 个答案:

没有答案