我已經添加了autoscript exe來與操作系統窗口(如上傳文件選擇窗口)進行通信。當我爲鉻瀏覽器運行我的腳本時,它工作正常,並且自動腳本也可以正常工作。但是當我啓動Internet Explorer Web驅動程序時,它不會將文件路徑發送到操作系統窗口。有人可以幫助解決這個問題嗎?AutoIt腳本不能與Internet Explorer一起工作
下面是示例代碼,它在我啓動瀏覽器時起作用,但在啓動IE時不起作用。我運行的testng.xml觸發瀏覽器 `
import io.github.bonigarcia.wdm.ChromeDriverManager;
import io.github.bonigarcia.wdm.InternetExplorerDriverManager;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import pom.LoginPom;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
/**
* Created by User on 28/5/2017.
*/
public class MyTest1 extends Tests{
private WebDriver driver;
@BeforeTest
@Parameters("Browser")
public void setup(String browser){
if (browser.equals("ie")) {
InternetExplorerDriverManager.getInstance().arch32().setup();
driver = new InternetExplorerDriver();
}
else if (browser.equals("chrome")){
ChromeDriverManager.getInstance().arch32().setup();
driver = new ChromeDriver();
}
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(5,TimeUnit.SECONDS);
driver.navigate().to("http://aspuploader.com/demo/form-singlefile.asp");
}
@Test
public void test1() throws InterruptedException, IOException {
WebElement elem = driver.findElement(By.id("myuploaderButton"));//.click();
JavascriptExecutor ja = (JavascriptExecutor) driver;
ja.executeScript("arguments[0].click();", elem);
Thread.sleep(3000);
Runtime.getRuntime().exec("src/test/java/script.exe");
}
@AfterMethod
public void close(){
driver.close();
}
}
`
以下是汽車它的腳本:
WinWait("Open","",3000)
ControlFocus("Open","","Edit1")
ControlSetText("Open","","Edit1","Hello")
ControlClick("Open","","Button1")
以下是簡單的AutoIt腳本 'WinWait( 「打開」, 「」,3000) ControlFocus( 「打開」, 「」, 「EDIT1」) ControlSetText( 「打開」, 「」,「EDIT1 「,」你好「) ControlClick(」打開「,」「,」Button1「)' –