2017-05-29 88 views
2

我已經添加了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") 
+0

以下是簡單的AutoIt腳本 'WinWait( 「打開」, 「」,3000) ControlFocus( 「打開」, 「」, 「EDIT1」) ControlSetText( 「打開」, 「」,「EDIT1 「,」你好「) ControlClick(」打開「,」「,」Button1「)' –

回答

0

有些時候,對於不同的瀏覽器絲毫不差,並w.r.t到AutoIt的文本更改。可能發生的情況是,您在Chrome瀏覽器中搜索的內容不適用於Internet Explorer。我建議重新檢查Internet Explorer的標題和文本。

+0

我已經檢查過。標題和文字是相同的。沒有區別。 –

相關問題