2017-05-29 49 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

我已经检查过。标题和文字是相同的。没有区别。 –

相关问题