【问题标题】:How to integrate cucumber with Jenkins如何将黄瓜与詹金斯集成
【发布时间】:2017-01-09 19:12:24
【问题描述】:

当我从 Jenkins 运行黄瓜测试时,我不断收到此错误。当我从 Eclipse 运行它时,我的测试非常好。我在詹金斯做错了什么?

[31m失败场景:[0m [31mGapLogin.feature:3 [0m#场景:登录Gap

1 个场景([31m1 失败[0m) 3个步骤([31m1失败[0m,[36m2跳过[0m] 0m22.931s

org.openqa.selenium.NoSuchElementException: 无法定位元素: {"method":"xpath","selector":".//*[@id='_GAPLogin_WAR_GAPLoginportlet_:userregform:userid']"} 命令持续时间或超时:15.10 秒 有关此错误的文档,请访问:http://seleniumhq.org/exceptions/no_such_element.html 构建信息:版本:'2.53.0',修订:'35ae25b',时间:'2016-03-15 17:00:58' 系统信息:主机:'B02176',ip:'10.105.129.9',os.name:'Windows 7',os.arch:'amd64',os.version:'6.1',java.version:'1.7.0_79 ' *** 元素信息:{Using=xpath, value=.//[@id='_GAPLogin_WAR_GAPLoginportlet_:userregform:userid']} 会话 ID:af49b00e-63c7-4710-b253-04410d0a8b61 驱动信息:org.openqa.selenium.firefox.FirefoxDriver 功能 [{platform=WINDOWS,acceptSslCerts=true,javascriptEnabled=true,cssSelectorsEnabled=true,databaseEnabled=true,browserName=firefox,handlesAlerts=true,nativeEvents=false,webStorageEnabled=true,rotatable=false,locationContextEnabled=true,applicationCacheEnabled=true , 需要屏幕截图=true, 版本=46.0}] 在 sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 在 sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) 在 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 在 java.lang.reflect.Constructor.newInstance(Constructor.java:526) 在 org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) 在 org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) 在 org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678) 在 org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363) 在 org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:500) 在 org.openqa.selenium.By$ByXPath.findElement(By.java:361) 在 org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:355) 在 main.java.GapDefinition.LogintoGap(GapDefinition.java:27) 在?。鉴于我登录了 To Gap 网站(GapLogin.feature:4) 原因:org.openqa.selenium.NoSuchElementException:无法定位元素:{"method":"xpath","selector":".//[@id='_GAPLogin_WAR_GAPLoginportlet_:userregform:userid']" } 有关此错误的文档,请访问:http://seleniumhq.org/exceptions/no_such_element.html 构建信息:版本:'2.53.0',修订:'35ae25b',时间:'2016-03-15 17:00:58' 系统信息:主机:'B02176',ip:'10.105.129.9',os.name:'Windows 7',os.arch:'amd64',os.version:'6.1',java.version:'1.7.0_79 ' 驱动程序信息:驱动程序版本:未知 在 .FirefoxDriver.prototype.findElementInternal_(file:///C:/Windows/TEMP/anonymous8675081044043132780webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:10770) 在 .fxdriver.Timer.prototype.setTimeout/<.notify>

:黄瓜失败

FAILURE:构建失败并出现异常。

  • 在哪里: 构建文件 'C:\Program Files (x86)\Jenkins\jobs\GapLogin\workspace\build.gradle' 行:14

  • 出了什么问题: 任务 ':cucumber' 执行失败。

    Process 'command 'C:\jdk1.7.0_79\bin\java.exe'' 以非零退出值 1 结束

  • 尝试: 使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。

构建失败

总时间:28.997 秒 构建步骤“调用 Gradle 脚本”将构建结果更改为 FAILURE 构建步骤“调用 Gradle 脚本”将构建标记为失败 完成:失败

【问题讨论】:

    标签: java jenkins cucumber build.gradle cucumber-jvm


    【解决方案1】:

    您的第一个问题是 NoSuchElementException。这是一个硒例外。 Selenium 无法定位元素。

    我会从您的 ci 服务器与您的本地环境不同以及 Theresienstadt 导致问题的角度来解决此问题。

    【讨论】:

    • 但是 selenium 能够通过 build.gradle 文件从 eclipse 和命令提示符中找到它。我不应该使用 selenium 独立服务器吗?谢谢
    • 问题可能是CI服务器不允许访问网页。或者,出于某种奇怪的原因,它看到了另一个网页。您的本地环境和 CI 服务器之间存在差异。您需要先了解这种差异,然后才能解决您的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-30
    相关资源
    最近更新 更多