框架:Selenium+Java+testNG+Jenkins
背景:Jenkins部署在了Linux环境,在自己本地的Windows环境跑测试程序都没问题问题描述:因为Linux环境不能执行exe,所以直接在服务器上安装了PhantomJS,代码中这样描写的:
DesiredCapabilities caps = new DesiredCapabilities();
((DesiredCapabilities)caps).setJavascriptEnabled(true);
((DesiredCapabilities)caps).setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,"/opt/env/phantomjs-2.1.1-linux-x86_64/bin/phantomjs"); driver = new PhantomJSDriver(caps);
但是上传到Git上再用Jenkins来Build的时候,报错了,提示说找不到元素:
[ERROR - 2017-11-02T03:16:02.297Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1509592562254 phantomjs://platform/console++.js:263 in errororg.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: nulljava.lang.reflect.InvocationTargetExceptionCaused by: org.openqa.selenium.NoSuchElementException: {"errorMessage":"Unable to find element with name 'login_userName'"}
大家有什么经验来判断这到底是哪里的问题吗?