我们已安排 Jenkins 构建来创建 AWS VM,VM 已成功联机,但在归档工件时,作业失败并显示以下错误消息。
\n\nArchiving artifacts\nERROR: Step \xe2\x80\x98Archive the artifacts\xe2\x80\x99 aborted due to exception: \njava.lang.NoClassDefFoundError: Could not initialize class sun.nio.fs.LinuxNativeDispatcher\n at sun.nio.fs.LinuxUserDefinedFileAttributeView.copyExtendedAttributes(LinuxUserDefinedFileAttributeView.java:291)\n at sun.nio.fs.LinuxFileSystem.copyNonPosixAttributes(LinuxFileSystem.java:72)\n at sun.nio.fs.UnixCopyFile.copyFile(UnixCopyFile.java:267)\n at sun.nio.fs.UnixCopyFile.copy(UnixCopyFile.java:581)\n at sun.nio.fs.UnixFileSystemProvider.copy(UnixFileSystemProvider.java:253)\n at java.nio.file.Files.copy(Files.java:1274)\n at hudson.FilePath$31$1.visit(FilePath.java:2296)\n at hudson.util.DirScanner.scanSingle(DirScanner.java:44)\n at hudson.FilePath$ExplicitlySpecifiedDirScanner.scan(FilePath.java:2991)\n at hudson.FilePath$31.invoke(FilePath.java:2290)\n at hudson.FilePath$31.invoke(FilePath.java:2283)\n at hudson.FilePath.act(FilePath.java:1042)\n at hudson.FilePath.act(FilePath.java:1025)\n at hudson.FilePath.copyRecursiveTo(FilePath.java:2283)\n at jenkins.model.StandardArtifactManager.archive(StandardArtifactManager.java:61)\n at hudson.tasks.ArtifactArchiver.perform(ArtifactArchiver.java:235)\n at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)\n at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)\n at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)\n at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)\n at hudson.model.Build$BuildExecution.post2(Build.java:186)\n at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)\n at hudson.model.Run.execute(Run.java:1823)\n at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)\n at hudson.model.ResourceController.execute(ResourceController.java:97)\n at hudson.model.Executor.run(Executor.java:429)\nRun Code Online (Sandbox Code Playgroud)\n\n造成此问题的原因是什么以及如何解决?
\n我们正在使用Selenium和Java来自动化我们的Web应用程序.我们有工作代码在Windows操作系统上为三种浏览器(IE,Chrome,Firefox - 最新版本)运行自动化测试脚本.
我们已经要求在MAC操作系统上运行自动化测试脚本 - Safari浏览器.
环境细节:
MAC OS版本:macOS Sierra版本10.12.5
Safari浏览器版本:10.1.1(12603.2.4)
Selenium独立服务器版本:3.4.0
Java版本:1.8.0_112
已连接的MAC VM与VNC查看器(Sys管理团队为我们的测试提供了MAC VM).
在MAC上执行测试脚本时,下面的代码并没有最大化Safari浏览器,这对于Windows上的其他浏览器(IE,Chrome和Firefox)来说效果很好.由于这个原因,我们无法在应用程序上找到一些控件.
driver.manage().window().maximize();
Run Code Online (Sandbox Code Playgroud)
我们没有得到任何异常,代码正在执行但没有执行任何操作.
请帮助克服Safari浏览器最大化MAC问题.
真的,我认为我的问题已经解决了这个解决方案,尝试了代码来最大化Safari浏览器,但获得异常.
码:
SafariOptions options = new SafariOptions();
options.setUseCleanSession(true);
driver = new SafariDriver(options);
JavascriptExecutor jse = (JavascriptExecutor)driver;
String screenWidth = jse.executeScript("return screen.availWidth").toString();
String screenHeight = jse.executeScript("return screen.availHeight").toString();
int intScreenWidth = Integer.parseInt(screenWidth);
int intScreenHeight = Integer.parseInt(screenHeight);
org.openqa.selenium.Dimension d = new org.openqa.selenium.Dimension(intScreenWidth, intScreenHeight);
driver.manage().window().setSize(d);
Run Code Online (Sandbox Code Playgroud)
例外:
2017年8月7日下午3:11:53 org.openqa.selenium.remote.ProtocolHandshake createSession INFO:检测到的方言:线程"main"中的OSS异常org.openqa.selenium.NoSuchWindowException:无法满足使用窗口的请求因为无法找到窗口.(警告:服务器未提供任何堆栈跟踪信息)命令持续时间或超时:27毫秒构建信息:版本:'3.4.0',修订版:'5234b32',时间:'2017-03-10 09:04:52 - 0800'系统信息:主持人:'Mac.local',ip:'fe80:0:0:0:4c6:11dc:3f91:11f8%en0',os.name:'Mac OS X',os.arch:' x86_64',os.version:'10 .12.6',java.version:'1.8.0_121'驱动程序信息:org.openqa.selenium.safari.SafariDriver Capabilities [{applicationCacheEnabled = …