我正在尝试运行TestNG测试.我的项目组织是--src-> test-> java-> com-> shn-> library以下命令在Windows中运行良好但在Linux中运行失败.
mvn -X clean exec:java -Dexec.mainClass="com.shn.library.RunSuitesInParallel" -Dexec.classpathScope=test -e
Run Code Online (Sandbox Code Playgroud)
在运行相同命令的Linux中看到错误 -
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project UAF: An exception occured while executing the Java class. com.shn.library.RunSuitesInParallel -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project UAF: An exception occured while executing the Java class. com.shn.library.RunSuitesInParallel
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) …Run Code Online (Sandbox Code Playgroud) 我正在尝试在Google云端硬盘中自动上传文件功能.
用于传递参数的元素隐藏为height - 0px.
任何用户操作都不会使此元素可见.所以我需要一个工作来点击元素不可见.
<input type="file" style="height: 0px; visibility: hidden; position: absolute; width: 340px; font-size: inherit;" multiple=""/>
Run Code Online (Sandbox Code Playgroud)
上述元素的xpath是 -
//*[@class='goog-menu goog-menu-vertical uploadmenu density-tiny']/input
Run Code Online (Sandbox Code Playgroud)
我在用
WebDriver.findElement(By.xpath(<xpath>).sendKeys(<uploadFile>)
Run Code Online (Sandbox Code Playgroud)
例外 -
org.openqa.selenium.ElementNotVisibleException
Run Code Online (Sandbox Code Playgroud)
我尝试过使用JavascriptExecutor.但无法找到确切的语法.
需要访问模态iframe中的元素.
以下代码适用于FireFox驱动程序,而Chrome无效 -
String frameId = null;
List<WebElement> frameSet = driver.findElements(By.tagName("iframe"));
for (WebElement frameName : frameSet){
if(!(frameName.getAttribute("id").isEmpty()) && (frameName.getAttribute("id").contains("DlgFrame"))){
frameId = frameName.getAttribute("id");
}
}
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Logger.info("Switch to Frame - "+frameId);
driver.switchTo().frame(driver.findElement(By.id(frameId)));
Run Code Online (Sandbox Code Playgroud)
Chrome驱动程序是否支持switchTo.frame(<'frameId'>)?
使用Chrome驱动程序时出错 -
org.openqa.selenium.WebDriverException:未知命令.选项:ActivateTab,CaptureEntirePage,CloseTab,DeleteCookie,...
命令持续时间或超时:220毫秒构建信息:版本:'2.25.0',修订版:'17482',时间:'2012-07-18 22:18:01'系统信息:os.name:'Windows 7', os.arch:'amd64',os.version:'6.1',java.version:'1.7.0_05'驱动程序信息:driver.version:RemoteWebDriver会话ID:cbde65cb0394ee0434b3bb528918ce40 at org.openqa.selenium.remote.ErrorHandler.createThrowable(位于org.openqa.selenium的org.openqa.selenium.remote.remote.selen上的org.openqa.selenium.remote.RemoteWebDriver.exe(RemoteWebDriver.java:498)org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)中的ErrorHandler.java:188 .remote.RemoteWebElement.execute(RemoteWebElement.java:244)atg.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:87)at com.shn.services.Office365.sharePointUploadFile(Office365.java:173)at at org.apache.maven.surefire.tes上的org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:74)中的com.shn.test.RunOffice365Test.testSharePointUploadAndDeleteFile(RunOffice365Test.java:55)tg.Test.GX.TestSuiteInProcess(SurefireBooter.java)中的org.apache.maven.surefire.Surefire.run(Surefire.java:180)上的Tng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:92) 350)at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)
我需要并行运行多个测试套件。一种方法是创建如下的套件文件-
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="AllTests" verbose="8">
<suite-files>
<suite-file path="./Suite1.xml"></suite-file>
<suite-file path="./Suite2.xml"></suite-file>
</suite-files>
</suite>
Run Code Online (Sandbox Code Playgroud)
创建一个如下所示的类-
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import javax.xml.parsers.ParserConfigurationException;
import org.testng.xml.Parser;
import org.testng.xml.XmlSuite;
import org.testng.TestNG;
import org.xml.sax.SAXException;
public class RunSuitesInParallel{
public static void main(String[] args) throws FileNotFoundException, ParserConfigurationException, SAXException, IOException {
TestNG testng = new TestNG();
testng.setXmlSuites((List <XmlSuite>)(new Parser("src"+File.separator+"test"+File.separator+"resources"+File.separator+"xml_Suites"+File.separator+"AllTests.xml").parse()));
testng.setSuiteThreadPoolSize(2);
testng.run();
}
}
Run Code Online (Sandbox Code Playgroud)
当我从Eclipse IDE运行该代码时,可以实现上述目标。我如何从Maven命令行运行它?
POM.xml的片段-
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<include>com/shn/test/*Tests.class</include>
<suiteXmlFiles>
<!-- <suiteXmlFile>src/test/resources/TestNG.xml</suiteXmlFile> -->
<suiteXmlFile>${tests}</suiteXmlFile>
</suiteXmlFiles>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
当前执行我使用的任何给定的XML- …
据我所知,屏幕截图功能基本上就像绘制 DOM 一样。由于 URL 不是 DOM 的一部分,因此屏幕截图不包含 URL。但是有什么解决方法可以捕获 URL 作为屏幕截图的一部分吗?