java在完成autoIt执行后将控制权返回Selenium测试执行
我正在编写一个selenium自动化测试脚本,其中包括将我的图片作为配置文件图片上传到门户中。该过程执行成功,直到我调用在Windows资源管理器框中加载图片并点击打开的但不考虑这3点代码之后的^ {CD1> }函数。总结一下我的担忧——“在runAutoIt()
方法之后,控件不会继续执行selenium
这是我的selenium代码,我在其中调用了runAutoIT()
函数
package com.cstudymaven.testscript;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.Test;
import com.cstudymaven.utilities.ReadExcel;
import com.cstudymaven.pompages.EditProfile;
import com.cstudymaven.pompages.SignInPage;
import com.cstudymaven.utilities.BaseTest;
public class TestScript extends BaseTest
{
SignInPage signin = null;
EditProfile edprf=null;
@Test
public void signUp()
{
JavascriptExecutor js = (JavascriptExecutor) driver;
String[][] credentials = ReadExcel.getData(filePath, "User_Login");
try {
for (int i = 1; i < credentials.length; i++) {
String email = credentials[0];
String password = credentials[1];
signin = new SignInPage(driver);
signin.clickonLogin();
Thread.sleep(1500);
signin.enterEmail(email);
Thread.sleep(1500);
signin.enterPassword(password);
signin.clicktoStart();
edprf=new EditProfile(driver);
wait = new WebDriverWait(driver, 10);
Thread.sleep(1500);
edprf.editprofile();
Thread.sleep(1500);
edprf.gotoprofile();
Thread.sleep(1500);
edprf.editlogo();
wait = new WebDriverWait(driver, 10);
Thread.sleep(2700);
edprf.camera();
Thread.sleep(2500);
edprf.cfile();
Thread.sleep(1500);
runAutoIT();
((JavascriptExecutor) driver).executeScript("window.focus();");
js.executeScript("window.scrollBy(0,150)");
WebElement upld
=driver.findElement(By.xpath("//button[@type='submit']"));
upld.click();
}
}
catch (Exception e)
{
e.printStackTrace();
try
{
}
catch (Exception e1)
{
}
}
}
public void runAutoIT() throws Exception
{
String strFilePath="C:\\Users\\LOBO\\1Amanfred.jpg";
String strPath="C:\\Users\\LOBO\\eclipse-
workspace\\CaseStudyMaven\\InputData\\cstudymaven.exe";
String strParameter=strPath+" "+strFilePath;
Runtime.getRuntime().exec(strParameter);
}
}
我已经尝试过使用window focus方法并插入没有在try catch块中执行的代码,但没有成功。runAutoit()函数之后的程序代码行不执行
我希望测试执行在runAutoit()函数之后单击upload按钮,但实际上,在成功执行runAutoit()方法之后,执行就会停止。控制台中没有错误消息
# 1 楼答案
虽然我晚了几年,但以下几点对你或其他人有所帮助:
# 2 楼答案
就像您在两个AutoIT方法之间诱导硬编码
Thread.sleep(1500);
的方式一样:诱导一些在
runAutoIT();
之后等待,等待过程结束,然后尝试将焦点保持在硒上,如下所示:你可以在Return control to Selenium after executing an AutoIt script中找到类似的讨论
# 3 楼答案