• <legend id='GckXS'><style id='GckXS'><dir id='GckXS'><q id='GckXS'></q></dir></style></legend>

    <small id='GckXS'></small><noframes id='GckXS'>

        <bdo id='GckXS'></bdo><ul id='GckXS'></ul>
      <tfoot id='GckXS'></tfoot>

      1. <i id='GckXS'><tr id='GckXS'><dt id='GckXS'><q id='GckXS'><span id='GckXS'><b id='GckXS'><form id='GckXS'><ins id='GckXS'></ins><ul id='GckXS'></ul><sub id='GckXS'></sub></form><legend id='GckXS'></legend><bdo id='GckXS'><pre id='GckXS'><center id='GckXS'></center></pre></bdo></b><th id='GckXS'></th></span></q></dt></tr></i><div id='GckXS'><tfoot id='GckXS'></tfoot><dl id='GckXS'><fieldset id='GckXS'></fieldset></dl></div>

      2. 如何自动化运行单击链接到 Web 应用程序的 Swing Java Web 启动应用程序,该应用程序由 Selenium

        时间:2023-07-13

            <tbody id='dP421'></tbody>

          <small id='dP421'></small><noframes id='dP421'>

            <tfoot id='dP421'></tfoot>

            <i id='dP421'><tr id='dP421'><dt id='dP421'><q id='dP421'><span id='dP421'><b id='dP421'><form id='dP421'><ins id='dP421'></ins><ul id='dP421'></ul><sub id='dP421'></sub></form><legend id='dP421'></legend><bdo id='dP421'><pre id='dP421'><center id='dP421'></center></pre></bdo></b><th id='dP421'></th></span></q></dt></tr></i><div id='dP421'><tfoot id='dP421'></tfoot><dl id='dP421'><fieldset id='dP421'></fieldset></dl></div>
                  <bdo id='dP421'></bdo><ul id='dP421'></ul>
                  <legend id='dP421'><style id='dP421'><dir id='dP421'><q id='dP421'></q></dir></style></legend>
                • 本文介绍了如何自动化运行单击链接到 Web 应用程序的 Swing Java Web 启动应用程序,该应用程序由 Selenium WebDriver 自动化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个典型的 Web 应用程序,它由 Selenium WebDriver 自动化.我的问题是一个特殊的自动化案例,其中我有一个链接,它使用 Java Web Start 运行一个 Swing 应用程序,我想将自动化控制权转移到 Swing 应用程序.这可能吗?我可以使用什么工具来做到这一点?而且,我该怎么做?提前致谢.

                  I have a typical web application, which is automated by Selenium WebDriver. My problem is a particular case of automation in which I have a link, which runs a swing app with Java Web Start, and I would like to transfer the control of the automation to the Swing app. is this possible? What tool can I use to do it? and, how can I do it? Thanks in advance.

                  推荐答案

                  1. 点击webdriver中的jnlp文件链接,将jnlp文件保存到磁盘;
                  2. 从 jnlp 运行 webstart 应用;
                  3. 捕获打开的应用并将其用于测试.

                  可以使用以下库来完成:

                  It can be done by using following libraries:

                  • netx (http://jnlp.sourceforge.net/netx/) - 用于运行 webstart来自 jnlp 的应用程序
                  • uispec4j (http://www.uispec4j.org/) - 用于拦截创建的 webstart 窗口和操作窗口元素
                  • netx (http://jnlp.sourceforge.net/netx/) - for running webstart application from jnlp
                  • uispec4j (http://www.uispec4j.org/) - for intercepting created webstart window and manipulating window elements

                  你可能可以用其他 AWT/Swing 测试工具做同样的事情,但是 uispec4j 允许拦截从 jnlp 执行的 webstart 应用程序,你不需要通过调用 main() 来运行应用程序,你不需要在您的测试代码仓库中包含您的 webstart 应用程序源代码.我在使用其他库(包括 Jemmy)时遇到了问题.

                  You can probably do the same trick with other AWT/Swing testing tool, but uispec4j allows to intercept webstart app executed from jnlp, you don't need to run the app by calling main() and you don't need to have your webstart app source code in your testing code repo. I had problems to achieve this with other libs, including Jemmy.

                  这对我有用:

                  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 会拦截窗口,所以它不会变得可见.这对我来说不是问题,所以我没有调查是否可以让它可见.

                  Note: uispec4j will intercept the window, so it won't become visible. It wasn't a problem for me, so I didn't investigate if making it visible is possible.

                  这篇关于如何自动化运行单击链接到 Web 应用程序的 Swing Java Web 启动应用程序,该应用程序由 Selenium WebDriver 自动化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何从 RemoteWebDriver 服务器而不是本地 FirefoxDriver 获取屏幕截图? 下一篇:如何在 C# 中使用 WebDriver 获取指定元素的屏幕截图

                  相关文章

                      <small id='PduDn'></small><noframes id='PduDn'>

                    1. <legend id='PduDn'><style id='PduDn'><dir id='PduDn'><q id='PduDn'></q></dir></style></legend>
                    2. <i id='PduDn'><tr id='PduDn'><dt id='PduDn'><q id='PduDn'><span id='PduDn'><b id='PduDn'><form id='PduDn'><ins id='PduDn'></ins><ul id='PduDn'></ul><sub id='PduDn'></sub></form><legend id='PduDn'></legend><bdo id='PduDn'><pre id='PduDn'><center id='PduDn'></center></pre></bdo></b><th id='PduDn'></th></span></q></dt></tr></i><div id='PduDn'><tfoot id='PduDn'></tfoot><dl id='PduDn'><fieldset id='PduDn'></fieldset></dl></div>

                      <tfoot id='PduDn'></tfoot>
                        <bdo id='PduDn'></bdo><ul id='PduDn'></ul>