简体   繁体   中英

Selenium->Automation planning->How to Execute Majority of the TestCases at a time?

iam学习selenium以便在我的应用程序上重现它。所以,请通过回答我的问题帮助我.1)如何通过使用自动化工具(selenium 2)一次执行大量的测试用例?)如何启动我的应用程序进行测试自动化工具selenium rc?

To use selenium API, you need to download the needed .jar files from here

Once you add the needed .jar files to your projects classpath, you are ready to start doing testing.

Here a very simple hello world application example that can help you understand selenium tests. (As you see there is no call to main or anithing similar, the tests will run automatically when the application is launched)

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;    
import junit.framework.TestCase;

public class HelloSeleniumTest extends TestCase {

    private Selenium browser;

    public void setUp() {

        browser = new DefaultSelenium("localhost",

            4444, "*firefox", "http://www.google.com");

        browser.start();

    }



    public void testGoogle() {

        browser.open("http://www.google.com/webhp?hl=en");

        browser.type("q", "hello world");

        browser.click("btnG");

        browser.waitForPageToLoad("5000");

        assertEquals("hello world - Google Search", browser.getTitle());

    }



    public void tearDown() {

        browser.stop();

    }

}

Before you run the app, you should start the RC server from the console. It is very simple, just:

1- Go to the Selenium-Server folder using the console (The place where are the files that you downloaded)

2- execute java -jar selenium-server.jar

Once is running, go back to your programming IDE and run the application

Also you have the possibility of downloading the Selenium plugin for firefox, that will create for you the java code when you navigate the pages so your testing will go faster. This is how it looks like:

在此输入图像描述

If something still unclear, visit this link , it is very well explained.

下载带有样本测试的演示并尝试使用它

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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