-4

Im trying to open a page using java and selenium on port 8080. Ive tried using the page and :8080 but the page continually keeps opening on a different port. Im basically trying to use zap and it configured to use firefox on port 8080. ANy help appreciated. Ive added my test and my class thats added to the test below, i think somewhere int he driver part it must call a different port but i cant see how this is happening

Test:

public class ZapScanTest  {
static Logger log = Logger.getLogger(ZapScanTest.class.getName());
private final static String ZAP_PROXYHOST = "127.0.0.1";
private final static int ZAP_PROXYPORT = 8080;
private final static String ZAP_APIKEY = null;

// Change this to the appropriate driver for the OS, alternatives in the 
drivers directory
private final static String FIREFOX_DRIVER_PATH = 
"drivers/geckodriver.exe";
private final static String MEDIUM = "MEDIUM";
private final static String HIGH = "HIGH";
private ScanningProxy zapScanner;
private Spider zapSpider;
private WebDriver driver;
private Dec myApp;
private final static String[] policyNames = {"directory-browsing","cross- 
site-scripting","sql-injection","path-traversal","remote-file- 
inclusion","server-side-include",
        "script-active-scan-rules","server-side-code-injection","external- 
redirect","crlf-injection"};
int currentScanID;


@Before
public void setup() {
    zapScanner = new 
ZAProxyScanner(ZAP_PROXYHOST,ZAP_PROXYPORT,ZAP_APIKEY);
    zapScanner.clear(); //Start a new session
    zapSpider = (Spider)zapScanner;
    log.info("Created client to ZAP API");
    driver = DriverFactory. createProxyDriver("firefox",createZapProxyConfigurationForWebDriver(), FIREFOX_DRIVER_PATH);


    myApp = new Dec(driver);
    //myApp.registerUser(); //Doesn't matter if user already exists, bodgeit just throws an error
}

@After
public void after() {
    driver.quit();
}

@Test
public void testSecurityVulnerabilitiesBeforeLogin()throws Exception  {
    myApp.login();
    log.info("Spidering...");
    spiderWithZap();
    log.info("Spider done.");

    setAlertAndAttackStrength();
    zapScanner.setEnablePassiveScan(true);
    scanWithZap();

    List<Alert> alerts = filterAlerts(zapScanner.getAlerts());
    logAlerts(alerts);
    assertThat(alerts.size(), equalTo(0));
}

Dec class:

public class Sportdec {
WebDriver driver;
final static String BASE_URL = "https://web-game-stage.dec.com/games:8080";
final static String USERNAME = "dec2009@hotmail.com";
final static String PASSWORD = "tables";

public Dec(WebDriver driver) {


    this.driver = driver;
    this.driver.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS);
    this.driver.manage().timeouts().implicitlyWait(5,TimeUnit.SECONDS);
}

public void login()throws Exception {
    driver.get(BASE_URL);
    Header header = new Header();
    header.guest_select_login();
    Pages.Login login = new Pages.Login();

    login.login_with_empty_fields();

    login.login_with_invalid_email();

    login.email_or_password_incorrect();


    login.login_open_and_close();

}

f1sh
  • 11,489
  • 3
  • 25
  • 51
FearghalQA
  • 255
  • 1
  • 2
  • 11
  • 3
    Can you paste the URL how did your try ? – NarendraR Mar 05 '19 at 09:51
  • 1
    Can you post the code and URL you are trying to access? – Sid Mar 05 '19 at 09:51
  • Added the code tehre, i think somewhere in the webdriver opening its causing a different port to be opened. I just need it to open on 8080. Currently its actually showing an empty page – FearghalQA Mar 05 '19 at 10:01
  • the port has to be specified after the hostname, not after the path in the url... – f1sh Mar 05 '19 at 10:40
  • *Any chance of removing some of these downvotes :D* Yes for that you need to delete the question. complementary you will get a badge :) – NarendraR Mar 05 '19 at 11:08

1 Answers1

1

By any chance have you tried using this

final static String BASE_URL = "https://web-game-stage.dec.com:8080/games";

instead of this

final static String BASE_URL = "https://web-game-stage.dec.com/games:8080";

You are adding port number to the games directory instead of the host

Zoe
  • 27,060
  • 21
  • 118
  • 148