Selenium multi-threaded startup grid Distributed test framework package (III)

Source: Internet
Author: User

Vii. tool class, Thread monitor class creation

Utils package, create Java class: Remotethreadstatusmonitor.java

Package com.lingfeng.utils;/** * This monitor method is important, and if not, causes the JVM to exit and all remotely working threads to throw an exception. * @author Ling Feng * */public class Remotethreadstatusmonitor implements Runnable {private String drivername;private Thread thre ad;private static int deadthreadcount = 0;//records the number of threads that have ended. public static int Getdeadthreadcount () {return deadthreadcount;} Public remotethreadstatusmonitor (String drivername,thread thread) {this.drivername=drivername;this.thread = thread;} @Overridepublic void Run () {//determines if the thread is still alive while (Thread.isalive ()) {}deadthreadcount++; System.out.println (drivername+ "Run End");}}

It contains the printed debug code, which can be removed by itself

Eight, test code, remote services open Baidu home Selenium code

Create Java class in Staticpage package: Remoteserveropenhomepage

Package Com.lingfeng.staticpage;import Org.openqa.selenium.by;import Org.openqa.selenium.webdriver;import Com.lingfeng.utils.remoteserverinit;public class Remoteserveropenhomepage implements Runnable {private Webdriver driver;//This method is used to store the startup name of the browser, which is used for subsequent scripts with the bug's name setting, and so on. Private String drivername;public remoteserveropenhomepage (webdriver driver,string drivername) {this.driver = driver; This.drivername=drivername;} /** * Overrides the Run method, and all the portals that need to run the script can be written in this method for multi-threaded invocation. */@Overridepublic void run () {int i = 1;while (i<=3) {String URL = remoteserverinit.gethomepage ();d river.get (URL); Driver.findelement (By.id ("kw")). SendKeys ("haha");d river.findelement (by.id ("su")). Click (); System.out.println (drivername+ "=====" +i+ "second Start"); i++;} Driver.close ();}}

The two classes in this blog post are all the classes that create multithreading, the monitoring thread in the first article, and the running thread, which can be removed by the printed debug code itself.

Not to be continued!!! Come on NOW!!!

Selenium multi-threaded startup grid Distributed test framework package (III)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.