Selenium WebDriver에 의해 자동화 된 일반적인 웹 애플리케이션이 있습니다. 내 문제는 Java Web Start로 스윙 앱을 실행하는 링크가 있고 자동화 제어를 Swing 앱으로 이전하고 싶은 자동화의 특정 사례입니다. 이것이 가능한가? 이를 위해 어떤 도구를 사용할 수 있습니까? 그리고 어떻게 할 수 있습니까? 미리 감사드립니다.
다음 라이브러리를 사용하여 수행 할 수 있습니다.
다른 AWT / Swing 테스트 도구로 동일한 트릭을 수행 할 수 있지만 uispec4j는 jnlp에서 실행되는 웹 스타트 앱을 가로 챌 수 있습니다. main ()을 호출하여 앱을 실행할 필요가 없으며 웹 스타트가 필요하지 않습니다. 테스트 코드 저장소의 앱 소스 코드. Jemmy를 포함한 다른 libs로 이것을 달성하는 데 문제가 있습니다.
나를 위해 일한 것은 다음과 같습니다.
import java.io.File;
import javax.swing.JTextField;
import netx.jnlp.JNLPFile;
import netx.jnlp.Launcher;
import org.junit.Assert;
import org.junit.Test;
import org.uispec4j.Trigger;
import org.uispec4j.UISpecAdapter;
import org.uispec4j.UISpecTestCase;
import org.uispec4j.Window;
import org.uispec4j.interception.WindowInterceptor;
public class WebstartTest extends UISpecTestCase {
@Test
public void test() throws Exception {
// click your webdriver link, save the jnlp file to disk
final File file = new File("file.jnlp");
final JNLPFile jnlp = new JNLPFile(file.toURI().toURL());
// adapter is a UISpec4j way to allow capturing windows created in
// non-standard way, exactly what we need.
this.setAdapter(new UISpecAdapter() {
@Override
public Window getMainWindow() {
return WindowInterceptor.run(new Trigger() {
@Override
public void run() throws Exception {
// running jnlp by netx launcher
Launcher launcher = new Launcher();
launcher.setCreateAppContext(false);
launcher.launch(jnlp);
}
});
}
});
Window w = this.getMainWindow();
// verify if window's components are there
Assert.assertEquals("text", ((JTextField) w.getSwingComponents(JTextField.class)[0]).getText());
// manipulate window components...
}
}
참고 : uispec4j는 창을 가로 채기 때문에 표시되지 않습니다. 나에게는 문제가 아니었기 때문에 가시화가 가능한지 조사하지 않았습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다