2

I need you guys advice. I created Selenium Automation script in Java for our testers. However, testers do not prefer to using Selenium Script which is not tester-friendly interface. Hence, what I am going to do is to develop a client program that interacts with selenium code that I developed. Say, they simply open the client GUI program and tick the check boxes they want to test and enter the testing detail and run it.

The probelm is that I don't know where I start from to make this client program. If it is possilbe to do so, what GUI framework or language is recommended?

Thank you in advance.

3
  • 1
    If I understood it correctly, you can use Jenkin. Create a job, parameterized it, give it to any one, tell them to execute from Jenkin GUI. At the end of job execution, they can see results. Commented Nov 26, 2021 at 6:47
  • 1
    @QualityMatters Even you can schedule the Jenkins job :) Commented Nov 26, 2021 at 7:28
  • Oh Thank you Q. Really appreciated that. Commented Nov 26, 2021 at 23:37

2 Answers 2

3

Yes. You can do that.

  • Create a GUI using Java Swing

  • In ActionListeners integrate your selenium code.

This project I created by using both Java Swing and Selenium. You can refer the code for your purpose.

How to integrate selenium with GUI?

  • Let's say your automation scripts needs to be executed in multiple environments.

  • Create UI by providing a drop-down or radio buttons to select environment.

  • Provide a button called Execute to run your scripts. In ActionListner of Execute button you need to integrate your selenium code.

Sample code:

public class FrameSample extends JFrame {

    JPanel pane;
    JButton execute = new JButton("Execute");

    public FrameSample() {

        /* Properties of JPanel */
        pane = new JPanel(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();

        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.fill = GridBagConstraints.EAST;
        gbc.gridwidth = 2;
        gbc.insets = new Insets(0, 0, 0, 0);
        pane.add(execute, gbc);

        setName("Automation");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLayout(new BorderLayout());
        setSize(300, 300);
        setContentPane(pane);
        setResizable(false);
        setLocationRelativeTo(null);
        setVisible(true);
        setAlwaysOnTop(true);

        execute.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    System.setProperty("webdriver.chrome.driver",
                            System.getProperty("user.dir") + "//Drivers//chromedriver.exe");
                    WebDriver driver = new ChromeDriver();
                    driver.manage().window().maximize();
                    driver.get("https://www.google.com");
                    Thread.sleep(5000);
                    // Do yuor stuff
                } catch (InterruptedException e1) {
                    e1.printStackTrace();
                }
            }
        });
    }

    public static void main(String[] args) {
        new FrameSample();
    }
}

Output:

enter image description here

Imports:

import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
Sign up to request clarification or add additional context in comments.

3 Comments

Can you add the required imports please?
@DebanjanB Added imports :)
Thank you Nandan. It is really helpful.
0

You don't need to create a UI from scratch, there are some tools that you can use for that particular purpose, for example Jenkins.

Jenkins is a CI/CD tool that helps us to trigger our automated tests, no matter which automation framework you are using you can integrate your tests there, but you can also use this tool as a UI to trigger your tests suite.

So, if your team needs to run some tests they should be able to do it directly on Jenkins. You just need to create a new Jenkins job and configure it base on your needs and then provide the link to your peers. You can make it as easy as you want, from a single button or as hard as having many options, is up to your needs.

If you want to know more about how to use Jenkins you can find several courses just by typing "Jenkins" in youtube, Udemy or any other learning platform, it is pretty easy, you will save tons of time an energy with it.

1 Comment

Thank you. It's been a while since I posted a question here. Already implemented the Jenkins and it works well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.