预期行为:
应启动Chromedriver流程并打开Chrome浏览器,同时通过命令提示符运行我的TestNG测试套件
实际行为:
实例化了testng.xml,但在通过命令提示符运行时未实例化Chromedriver 通过命令提示符和testng运行测试时,我看不到chrome.exe出现在任务管理器中通过带有TestNG的Eclipse IDE运行测试时运行正常 重现的步骤 -
webdriver.chrome.driver
系统属性PATH
环境变量中添加了chromedriver exe路径和Chrome浏览器exe路径
这是我的“路径”PATH = C:\ ProgramData \甲骨文\爪哇\ javapath;%JAVA_HOME%\ bin中; C:\程序 文件\的Java \ jdk1.8.0_77 \ BIN; C:\用户\ mbr9 \工作区\ FinalAutomation \ lib中; C:\ PROGRAM 文件(x86)\ Google \ Chrome \ Application; C:\ Program Files \ Microsoft MPI \ BIN \; C:\ PROGRA〜1 \ ds_shell \代码\ BIN \ ds_shell; C:\ Oracle11gR2_32bCli \的Client_1 \ BIN; C:\ Oracle11gR2_64bCli \的Client_1 \ BIN; C:\ Windows \ System32下; C:\视窗; C:\ WINDOWS \ SYSTEM32 \ WBEM; C:\ WINDOWS \ SYSTEM32 \ WindowsPowerShell \ V1.0 \; C:\ PROGRAM 文件(x86)\ Microsoft SQL Server \ 90 \ Tools \ binn \; C:\ Progr am Files \ Microsoft \ Web Platform Installer \; C:\ Program Files (x86)\ Microsoft ASP.NET \ ASP.NET网页\ v1.0 \; C:\ Program Files (x86)\ Windows Kits \ 8.0 \ Windows Performance Toolkit \; C:\ Program Files \ Microsoft SQL Server \ 110 \ Tools \ Binn \; C:\ Program Files (x86)\ Lenovo \ Access Connections \; C:\ Program Files \ Lenovo \ Fingerprint Manager Pro \; C:\ Program Files \ Intel \ WiFi \ bin \; C:\ Program Files \ Common Files \ Intel \ WirelessCommon \; c:\ Program Files \ ThinkPad \ Bluetooth 软件\; c:\ Program Files \ ThinkPad \ Bluetooth Sof tware \ syswow64; testngchromedrivecommandprompt
能够手动运行C:\ Program Files(x86)\ Google \ Chrome \ Application \ chrome.exe
我的testng测试在使用Chromedrive的Eclipse IDE中运行良好,问题在于通过commandprompt运行它们。这些testng测试在Firefox运行时通过命令提示符运行得很好6.通过命令提示符键入“chromedriver”打开了chromedriver进程,即我收到此消息:
启动ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4)在9515港口只有当地的 允许连接。
这是我的代码:
public class TestNGMyClass {
public static WebDriver driver1;
@BeforeMethod // @BeforeTest
public void setup() {
System.setProperty("webdriver.chrome.driver", "C:\Users\mbr9\workspace\FinalAutomation\lib\chromedriver.exe");
driver1 = new ChromeDriver();
driver1.manage().window().maximize();
driver1.navigate().refresh();
driver1.manage().deleteAllCookies();
driver1.navigate().to("https://www.google.com");
}
}