Ignore:
Timestamp:
2018-12-16T19:29:19+13:00 (5 years ago)
Author:
ak19
Message:

Merging Selenium with AssertJ Swing stuff in first tutorial test java class. And it works!

Location:
gs3-extensions/testing/trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/testing/trunk/src/build.xml

    r32687 r32688  
    110110  <echo>GSDLHOME: ${env.GSDLHOME}</echo> 
    111111  <java classname="org.junit.runner.JUnitCore" dir="${gli.home}" fork="true" maxmemory="256m" classpathref="tutorials.path">
     112    <!--https://stackoverflow.com/questions/38676719/selenium-using-java-the-path-to-the-driver-executable-must-be-set-by-the-webdr-->
     113    <sysproperty key="webdriver.gecko.driver" path="${basedir}/geckodriver"/>
    112114    <arg value="gstests.tutorials.RunGLITest"/>
    113    
     115    <!-- TODO: for now hardcoding the GS3 URL. Toplevel build.xml can properly construct this
     116     URL, but hard to do so quickly here -->
     117    <jvmarg value="-DSERVERURL=http://127.0.0.1:8383/greenstone3/library "/>
    114118  </java>
    115119 
  • gs3-extensions/testing/trunk/src/src/gstests/tutorials/RunGLITest.java

    r32685 r32688  
    2525*/
    2626
     27// Junit imports
    2728import org.junit.AfterClass;
    2829import org.junit.Assert;
    2930import org.junit.Before;
    3031import org.junit.Test;
    31 import org.assertj.swing.data.Index;
    32      
     32
     33// GLI imports
    3334import org.greenstone.gatherer.Gatherer;
    3435import org.greenstone.gatherer.GathererProg; // main GLI class we'll be testing
    3536import org.greenstone.gatherer.Dictionary; // access to display strings
    3637
     38// Java GUI testing with AssertJ Swing
    3739import org.assertj.swing.junit.testcase.AssertJSwingJUnitTestCase;
    3840import org.assertj.swing.fixture.*;
    3941import org.assertj.swing.edt.GuiActionRunner;
    4042import org.assertj.swing.core.*;
     43import org.assertj.swing.data.Index;
     44
     45// Selenium
     46import org.openqa.selenium.By;
     47import org.openqa.selenium.WebDriver;
     48import org.openqa.selenium.WebElement;
     49import org.openqa.selenium.firefox.FirefoxDriver;
     50
     51// Helper classes for selenium and AssertJ Swing tests
     52import org.greenstone.gsdl3.testing.GSTestingUtil;
     53import org.greenstone.gsdl3.testing.GSGUITestingUtil;
     54
     55// Java imports
    4156import javax.swing.*;
     57
     58
    4259     
    4360// static imports
     
    4663
    4764public class RunGLITest extends AssertJSwingJUnitTestCase {
     65
     66    private static WebDriver _driver = new FirefoxDriver(); // selenium
     67   
    4868    private FrameFixture window;
     69
     70    // Selenium
     71    @Before
     72    public void init()
     73    {
     74    //https://stackoverflow.com/questions/38676719/selenium-using-java-the-path-to-the-driver-executable-must-be-set-by-the-webdr
     75    // GS3's build.xml would have set the webdriver.gecko.driver path System.Property to
     76    // the location of Firefox' geckodriver executable when launching this test class already.
     77    // So now we can continue to just do:
     78    _driver.get(System.getProperty("SERVERURL"));
     79    }
    4980   
    5081    @Override
     
    127158    tab.requireTitle(gatherPaneLabel, Index.atIndex(1));
    128159  }
    129  
    130    
     160
     161    // Selenium
     162    // called once and only once: to quit the firefox driver geckodriver
     163    @AfterClass
     164    public static void destroy()
     165    {
     166    _driver.quit();
     167    }
    131168}
Note: See TracChangeset for help on using the changeset viewer.