简体   繁体   English

Java中是否有针对WebDrive Selenium的虚拟项目测试用例?

[英]Is there any dummy project test cases for webdrive selenium in java?

I am a beginner in Selenium WebDrive. 我是Selenium WebDrive的初学者。 Is there any dummy projects or testcases that could help me start learning? 是否有任何虚拟项目或测试用例可以帮助我开始学习? Could you please suggest some starting points? 您能否提出一些起点?

You can just use a dummy class as shown below.. 您可以只使用一个伪类,如下所示。

import static org.junit.Assert.fail;

import java.util.concurrent.TimeUnit;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class TestExample {
  private WebDriver driver;
  private String baseUrl;
  private StringBuffer verificationErrors = new StringBuffer();

  @Before
  public void setUp() throws Exception {
    driver = new FirefoxDriver();
    baseUrl = "http://localhost:8080";
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
  }

  @Test
  public void testExample() throws Exception {
    driver.get(baseUrl);
  }

  @After
  public void tearDown() throws Exception {
    driver.quit();
  }
}

And just make sure you have the Selenium maven repo in your pom with junit. 只需确保您的pom中有带有junit的Selenium Maven存储库即可。

You can start with the following 您可以从以下内容开始

Getting Started Guide 入门指南

documentation 文件资料

more examples 更多例子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM