【发布时间】:2018-12-27 07:20:05
【问题描述】:
我正在编写一个 selenium 自动化测试脚本,其中涉及将我的图片作为个人资料图片上传到门户中。该过程成功执行,直到我调用 runAutoit() 函数,该函数将图片加载到 Windows 资源管理器框中并单击打开,但不考虑此点之后的 3 行代码。总结一下我的担忧 - “在runAutoIt() 方法之后,控件不会继续执行硒。
这是我调用 runAutoIT() 函数的 selenium 代码
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);
}
}
我已经尝试使用窗口焦点方法并在 try catch 块中插入未执行的代码,但没有成功。程序中runAutoit()函数后的那行代码没有执行。
我希望测试执行在 runAutoit() 函数之后单击上传按钮,但实际上在成功执行 runAutoit() 方法后执行停止。控制台中没有错误信息。
【问题讨论】:
标签: java selenium selenium-webdriver focus autoit