Windows从属上的詹金斯无法找到元素

时间:2018-07-03 03:30:33

标签: jenkins protractor google-chrome-headless

我的量角器测试脚本在本地chrome浏览器上运行,但是当我将它们添加到jenkins时会抛出“ Unable to find element”。我将镀铬窗口的尺寸更改为1920 * 1080和800 * 600,但它们似乎都不起作用。有人可以帮我从过去的两天里坚持下来吗?

登录脚本位于onPrepare()中的config.js

ChromeDriver:2.38,
无头的Chrome浏览器:67,
directConnect = true,
在Windows Slave计算机上运行Jenkins。

-我的登录页面是非角度的。 (受限制的环境。因此,请手动编写错误日志)

我的Config.js:

  exports.config = {    
     chromeDriver: 'path/chromedriver_2.38.exe',
     framework: 'custom',
     frameworkpath: require.resolve('protractor-cucumber-framework'),

     capabilities:{ 
        'browserName':'chrome',
        'directConnect':'true',
            'chromeOptions':{
                'binary': 'path/chrome.exe',
                'args': ['--headless', '--window-size=1920,1080']
                'useAutomationExtension': false,
            }
     },

     onPrepare:function(){
        browser.waitForAngularEnables(true).then(Function(){
            return browser.driver.get("appurl");
    }).then(fucntion(){
        return browser.driver.findElement(by.xpath("userid")).sendKeys('XXXX');
    }).then(function(){
        return browser.driver.findElement(by.xpath("paswd")).sendKeys('xxxx');
    }).then(function(){
        return browser.driver.findELement(by.xpath("submitbutton")).click();
    }).then(fucntion(){
        return true;
    });

        return browser.driver.wait(fucntion(){
            return browser.driver.getCurrentUrl().then(fucntion(url){
                return expect(browse.driver.getTitle()).to.contain("XXXX");
    });
    }, 15000);
    },


Error in Jenkins:

[info] --maven-ng-protractor:0.0.2:run (ng-protractor)
[info] protractor:protractor
[info] Executing protractor test Suite ...

Command: <path>\config.js
[info] I/Launcher - Running 1 instances of webdriver
[info] I/Local - Starting selenium standalone server ...
[info]I/Local - Selenium standalone server started at http://xxx.xx.xx.xx:xxxx/wd/hub
[Info] E/Launcher - no such element: Unable to locate element:{"method":"xpath" , "selector":"//input[@id='userid']"}
[info] (Session info: headless chrome = 67.0.3396.99
    (Driver info: chromedriver=2.38.552522 (), platform = Windows NT 6.2.9200 X86_64)

0 个答案:

没有答案