<legend id='SjpLa'><style id='SjpLa'><dir id='SjpLa'><q id='SjpLa'></q></dir></style></legend>

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

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

        如何通过 main() 和 TestNG 在 IDE 中编写 Selenium Java 应用程序代码

        How to write Selenium Java Application code in IDE through main() and TestNG(如何通过 main() 和 TestNG 在 IDE 中编写 Selenium Java 应用程序代码)

          <tbody id='zDq0x'></tbody>

          1. <small id='zDq0x'></small><noframes id='zDq0x'>

            <legend id='zDq0x'><style id='zDq0x'><dir id='zDq0x'><q id='zDq0x'></q></dir></style></legend>
                <i id='zDq0x'><tr id='zDq0x'><dt id='zDq0x'><q id='zDq0x'><span id='zDq0x'><b id='zDq0x'><form id='zDq0x'><ins id='zDq0x'></ins><ul id='zDq0x'></ul><sub id='zDq0x'></sub></form><legend id='zDq0x'></legend><bdo id='zDq0x'><pre id='zDq0x'><center id='zDq0x'></center></pre></bdo></b><th id='zDq0x'></th></span></q></dt></tr></i><div id='zDq0x'><tfoot id='zDq0x'></tfoot><dl id='zDq0x'><fieldset id='zDq0x'></fieldset></dl></div>
              1. <tfoot id='zDq0x'></tfoot>
                • <bdo id='zDq0x'></bdo><ul id='zDq0x'></ul>
                  本文介绍了如何通过 main() 和 TestNG 在 IDE 中编写 Selenium Java 应用程序代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我面临以下问题在 Google 中搜索找不到明确的答案如何解决此问题.

                  I m facing the below issue searched in Google couldn't find the clear answer how to resolve this.

                  错误:

                  org.apache.bcel.verifier.exc.AssertionViolatedException.main(AssertionViolatedException.java:102)
                  

                  代码

                  import org.openqa.selenium.chrome.ChromeDriver;
                  
                  public class Newtours 
                  { 
                       public static ChromeDriver driver; 
                       public void chrome() 
                      {
                           System.setProperty("webdriver.chrome.driver","C:\Users\imper\Downloads\chromedriver_win32\chromedriver.exe"); // objects and variables instantiation 
                           driver = new ChromeDriver(); 
                           driver.get("newtours.demoaut.com/");
                      }
                  }
                  

                  推荐答案

                  错误源于org.apache.bcel.verifier

                  The error is stemming out of org.apache.bcel.verifier

                  你必须注意以下几点:

                  使用 WebDriver 接口代替 ChromeDriver 实现.chrome 是保留关键字.为 method 使用其他用户定义的名称,例如my_function() {}简单地定义 public void chrome() 不会执行您的 Test.您必须将 public void chrome() 转换为以下任一:

                  Instead of using the ChromeDriver implementation use the WebDriver interface. chrome is a reserved keyword. Use some other user defined name for the method e.g. my_function() {} Simply defining public void chrome() won't execute your Test. You have to convert public void chrome() in to either of the following :

                  • 转换成main()函数如下:

                      public class Newtours  
                      {
                          public static void main(String[] args) 
                          {
                              System.setProperty("webdriver.chrome.driver", "C:\path\to\chromedriver.exe");
                              WebDriver driver =  new ChromeDriver();
                              driver.get("http://newtours.demoaut.com/");
                          }
                      }
                  

                • 集成TestNG并添加@Test注解如下:

                • Integrate TestNG and add @Test annotations as follows :

                      import org.openqa.selenium.WebDriver;
                      import org.openqa.selenium.chrome.ChromeDriver;
                      import org.testng.annotations.Test;
                  
                      public class Newtours 
                      {
                          @Test
                          public void my_function()
                          {
                              System.setProperty("webdriver.chrome.driver", "C:\path\to\chromedriver.exe");
                              WebDriver driver = new ChromeDriver();
                              driver.get("http://newtours.demoaut.com/");
                          }
                      }
                  

                • 这篇关于如何通过 main() 和 TestNG 在 IDE 中编写 Selenium Java 应用程序代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)
                      <tbody id='Y0nwa'></tbody>

                      • <small id='Y0nwa'></small><noframes id='Y0nwa'>

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