Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6002187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:56:30+00:00 2026-05-23T00:56:30+00:00

The selenium tests I’m gonna be doing are basically based on three main steps,

  • 0

The selenium tests I’m gonna be doing are basically based on three main steps, with different parameters. These parameters are passed in from a text file to the test. this allows easy completion of a test such as create three of “X” without writing the code to do the create three times in one test.

Imagine i have a test involving creating two of “X” and one of “Y”. CreateX and CreateY are already defined in separate tests. Is there a nice way of calling the code contained in createX and createY from say, Test1?

I tried creating a class with the creates as seperate methods, but got errors on all the selenium.-anything-, ie every damn line. it goes away if i extend seleneseTestCase, but it seems that my other test classes wont import from a class that extends seleneseTestCase. I’m probably doing something idiotic but i might as well ask!

EDIT:
well for example, its gonna be the same setUp method for every test, so id like to only write that once… instead of a few hundred times…

public void ready() throws Exception 
{
    selenium = new DefaultSelenium("localhost", 4444, "*chrome", "https://localhost:9443/");
    selenium.start();
    selenium.setSpeed("1000");
    selenium.setTimeout("999999");
    selenium.windowMaximize();
}

thats gonna be used EVERYWHERE.
its in a class called reuseable. Id like to just call reuseable.ready(); from the tests SetUp… but it wont let me….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:56:31+00:00Added an answer on May 23, 2026 at 12:56 am
    public class ExampleTest {
        @Before
        public void setup() {
            System.out.println("setup");
        }
    
        public void someSharedFunction() {
            System.out.println("shared function");
        }
    
        @Test
        public void test1() {
            System.out.println("test1");
            someSharedFunction();
        }
    
        @Test
        public void test2() {
            System.out.println("test2");
            someSharedFunction();
        }
    }
    

    The contents of the function after the @Before annotation is what will be executed before every test. someSharedFunction() is an example of a ‘reusable’ function. The code above will output the following:

    setup
    test1
    shared function
    setup
    test2
    shared function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to run Selenium tests (PHP) from the command-line. I can only
In my ruby Selenium Tests there is a lot of the same code in
i need to run selenium tests in a headless mode using Xvfb, in the
I'm trying to run Selenium tests with Selenium-RC using TestNG on Eclipse. When I
I have a suite of Selenium tests (created using Java in Selenium RC 1.0.3)
So I've got a lot of PHPUnit tests (they are actually Selenium tests running
Here's the situation that I'm working with: Build tests in Selenium Get all the
I've created a suite of TestNG tests that I'm attempting to run from an
So I'm working on a large rails app that has a bunch of selenium
Is there a way to capture errors occurring in the DOM in Selenium and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.