Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97792

Building and running a Java Selenium Automation on Jenkins

$
0
0

I created an automation in Java that utilizes Selenium, ChromeDriver, and the JExcelApi. In order to simplify the distribution of this automation, I am attempting to add it to a Jenkins server (see more details from my previous StackOverflow post).

I have configured a Freestyle project on Jenkins that uses GitHub for its source code management. For the build environment preferences, I selected:

Delete workspace before build starts

Finally, selecting "Build Now" for this project executes the following shell:

javac src/GUI.java
java GUI 

When building the program on Jenkins, I am getting a variety of errors. First, the output says that my packages do not exist. Additionally, I am getting a variety of "cannot find symbol" errors. Finally, I am getting errors that say that a local variable cannot be accessed from within an inner class. Here is the detailed console output from Jenkins:

+ javac src/GUI.java
src/GUI.java:12: error: package Objects does not exist
import Objects.Product;
              ^
src/GUI.java:13: error: package Reader does not exist
import Reader.ReadExcel;
             ^
src/GUI.java:14: error: package Reader does not exist
import Reader.WriteExcel;
             ^
src/GUI.java:15: error: package co.mitch.selenium.runner does not exist
import co.mitch.selenium.runner.ActiveIQ;
                               ^
src/GUI.java:16: error: package co.mitch.selenium.runner does not exist
import co.mitch.selenium.runner.Ascend;
                               ^
src/GUI.java:17: error: package co.mitch.selenium.runner does not exist
import co.mitch.selenium.runner.LinkedIn;
                               ^
src/GUI.java:18: error: package jxl.read.biff does not exist
import jxl.read.biff.BiffException;
                    ^
src/GUI.java:19: error: package jxl.write does not exist
import jxl.write.WriteException;
                ^
src/GUI.java:20: error: package jxl.write.biff does not exist
import jxl.write.biff.RowsExceededException;
                     ^
src/GUI.java:395: error: cannot find symbol
    public static void performCreateWatchlist() throws BiffException, IOException, InterruptedException {
                                                       ^
  symbol:   class BiffException
  location: class GUI
src/GUI.java:440: error: cannot find symbol
    public static void performGetContactInformation(String username, String password, String path) throws InterruptedException, BiffException, IOException, RowsExceededException, HeadlessException, WriteException {
                                                                                                                                ^
  symbol:   class BiffException
  location: class GUI
src/GUI.java:440: error: cannot find symbol
    public static void performGetContactInformation(String username, String password, String path) throws InterruptedException, BiffException, IOException, RowsExceededException, HeadlessException, WriteException {
                                                                                                                                                            ^
  symbol:   class RowsExceededException
  location: class GUI
src/GUI.java:440: error: cannot find symbol
    public static void performGetContactInformation(String username, String password, String path) throws InterruptedException, BiffException, IOException, RowsExceededException, HeadlessException, WriteException {
                                                                                                                                                                                                      ^
  symbol:   class WriteException
  location: class GUI
src/GUI.java:91: error: local variable menuLabel is accessed from within inner class; needs to be declared final
                frame.remove(menuLabel);
                             ^
src/GUI.java:92: error: local variable centerPanel is accessed from within inner class; needs to be declared final
                frame.remove(centerPanel);
                             ^
src/GUI.java:103: error: local variable menuLabel is accessed from within inner class; needs to be declared final
                frame.remove(menuLabel);
                             ^
src/GUI.java:104: error: local variable centerPanel is accessed from within inner class; needs to be declared final
                frame.remove(centerPanel);
                             ^
src/GUI.java:115: error: local variable menuLabel is accessed from within inner class; needs to be declared final
                frame.remove(menuLabel);
                             ^
src/GUI.java:116: error: local variable centerPanel is accessed from within inner class; needs to be declared final
                frame.remove(centerPanel);
                             ^
src/GUI.java:182: error: local variable usernameField is accessed from within inner class; needs to be declared final
                username = usernameField.getText(); 
                           ^
src/GUI.java:183: error: local variable passwordField is accessed from within inner class; needs to be declared final
                password = passwordField.getText(); 
                           ^
src/GUI.java:184: error: local variable nameField is accessed from within inner class; needs to be declared final
                watchlistName = nameField.getText(); 
                                ^
src/GUI.java:185: error: local variable excelField is accessed from within inner class; needs to be declared final
                excelPath = excelField.getText(); 
                            ^
src/GUI.java:189: error: cannot find symbol
                } catch (BiffException | IOException | InterruptedException e2) {
                         ^
  symbol: class BiffException
src/GUI.java:252: error: local variable usernameField is accessed from within inner class; needs to be declared final
                username = usernameField.getText(); 
                           ^
src/GUI.java:253: error: local variable passwordField is accessed from within inner class; needs to be declared final
                password = passwordField.getText(); 
                           ^
src/GUI.java:254: error: local variable excelField is accessed from within inner class; needs to be declared final
                excelPath = excelField.getText(); 
                            ^
src/GUI.java:261: error: cannot find symbol
                } catch (RowsExceededException e1) {
                         ^
  symbol: class RowsExceededException
src/GUI.java:267: error: cannot find symbol
                } catch (BiffException e1) {
                         ^
  symbol: class BiffException
src/GUI.java:270: error: cannot find symbol
                } catch (WriteException e1) {
                         ^
  symbol: class WriteException
src/GUI.java:331: error: local variable usernameField is accessed from within inner class; needs to be declared final
                    performLinkedInHelp(usernameField.getText(), passwordField.getText());
                                        ^
src/GUI.java:331: error: local variable passwordField is accessed from within inner class; needs to be declared final
                    performLinkedInHelp(usernameField.getText(), passwordField.getText());
                                                                 ^
src/GUI.java:396: error: cannot find symbol
        ActiveIQ activeIQUser = new ActiveIQ();
        ^
  symbol:   class ActiveIQ
  location: class GUI
src/GUI.java:396: error: cannot find symbol
        ActiveIQ activeIQUser = new ActiveIQ();
                                    ^
  symbol:   class ActiveIQ
  location: class GUI
src/GUI.java:399: error: cannot find symbol
        ReadExcel excelReader = new ReadExcel(excelPath);
        ^
  symbol:   class ReadExcel
  location: class GUI
src/GUI.java:399: error: cannot find symbol
        ReadExcel excelReader = new ReadExcel(excelPath);
                                    ^
  symbol:   class ReadExcel
  location: class GUI
src/GUI.java:446: error: cannot find symbol
        ReadExcel excelReader = new ReadExcel(excelPath);
        ^
  symbol:   class ReadExcel
  location: class GUI
src/GUI.java:446: error: cannot find symbol
        ReadExcel excelReader = new ReadExcel(excelPath);
                                    ^
  symbol:   class ReadExcel
  location: class GUI
src/GUI.java:450: error: cannot find symbol
        Ascend run = new Ascend(); 
        ^
  symbol:   class Ascend
  location: class GUI
src/GUI.java:450: error: cannot find symbol
        Ascend run = new Ascend(); 
                         ^
  symbol:   class Ascend
  location: class GUI
src/GUI.java:470: error: cannot find symbol
        ArrayList<Product> output = new ArrayList<Product>(); 
                  ^
  symbol:   class Product
  location: class GUI
src/GUI.java:470: error: cannot find symbol
        ArrayList<Product> output = new ArrayList<Product>(); 
                                                  ^
  symbol:   class Product
  location: class GUI
src/GUI.java:493: error: cannot find symbol
        WriteExcel writer = new WriteExcel(); 
        ^
  symbol:   class WriteExcel
  location: class GUI
src/GUI.java:493: error: cannot find symbol
        WriteExcel writer = new WriteExcel(); 
                                ^
  symbol:   class WriteExcel
  location: class GUI
src/GUI.java:509: error: cannot find symbol
        LinkedIn run = new LinkedIn(); 
        ^
  symbol:   class LinkedIn
  location: class GUI
src/GUI.java:509: error: cannot find symbol
        LinkedIn run = new LinkedIn(); 
                           ^
  symbol:   class LinkedIn
  location: class GUI
Note: src/GUI.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
46 errors
Build step 'Execute shell' marked build as failure
Finished: FAILURE

From my research, I found that one possible solution would be to use a Maven project. However, I do not have any experience with Maven so this would be a difficult process. Is there a different shell command that I should use to make this build and run properly? I attempted to compile each source code file individually but that also returned errors:

javac src/Objects/Product.java
javac src/Reader/ReadExcel.java
javac src/Reader/WriteExcel.java
javac src/co/mitch/selenium/runnuer/ActiveIQ.java
javac src/co/mitch/selenium/runner/Ascend.java
javac src/co/mitch/selenium/running/LinkedIn.java
javac src/GUI.java
java GUI

If there is no way to make this work with a different shell command, what options do I have to get the automation to run correctly on the server? Thanks in advance for any help that you are able to provide.


Viewing all articles
Browse latest Browse all 97792

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>