0 votes
1 view
in Devops and Agile by (23.1k points)

I write automation tests in selenium (java) in the maven project. I have defined the download folder as:

public static String userDownloadDir = System.getProperty("user.dir") + File.separator + "target" + File.separator + "downloadFiles";

so the folder download files appear in target directory each time I download anything.

Also, I have assertion in my tests: if after clicking and downloading the directory has appeared in target path. when I run locally on Windows in IJ it works and assertion returns true(that directory is created) but when I run tests on Jenkins it returns false.

Assertion code:

 public boolean ifDirExists(){

   File tmpDir = new File(userDownloadDir);

    boolean exists = tmpDir.exists();

    if(exists) {

        logger.info("Directory was successfully created");

        return true;

    }

    return false;

}

can anybody help why it returns false? should I change especially path for downloading files for Jenkins or something else is wrong?

1 Answer

0 votes
by (58.7k points)

I am assuming that this is definitely because of the unsuccessful installation of Jenkins, here I have told about the complete Jenkins installation process, kindly follow the following steps to get it working:

Installing Jenkins

Start by downloading and installing Jenkins.

To download Jenkins, visit the Jenkins web site. Click the ‘Download’ button and choose the file that suits your OS.

To install Jenkins, 1st move the downloaded Jenkins.war file to an appropriate directory, e.g. C:Program FilesJenkins:

image

Then open a command prompt in this directory by clicking on the file path and typing ‘cmd’:

image

Once command prompt has opened, type and run the command java –jar Jenkins.war.

Once the command has run, a password will be generated for logging into Jenkins:

image
In this example the password is cd3f375e0baa47f4b4a5591f1e920bfe.
Note that this password can also be checked by referring to the InitialAdminPassword.txt file which has been created in the \.jenkins\secrets folder:
image
Jenkins Setup Next, open your browser and navigate to URL: localhost:8080:
image
The following screen will appear:
image
Enter your password then click the ‘Continue’ button.
On the next screen, choose the option ‘Select plugins to install’:
image
Some plugins will be defaulted already. These can be left as defaulted. Make sure that the following plugins are ticked: Ant Plugin (under Build Tools):
image
JUnit Plugin (under Build Analysis and Reporting):
image
If you want Jenkins to download the regression pack from your Version Control repository, also tick the relevant plugin under Source Code Management (e.g. the Git plugin):
image
Then click the ‘Install’ button. When this is completed, click the ‘Continue as admin’ button on the following screen (instead of filling out ‘Create First Admin User’):
image
Note that, the next time you log in, your username will be ‘admin’ and your password will be the one generated earlier. On the next screen, click the button ‘Start using Jenkins’ to complete the setup.
image
I hope this helps!
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...