如何在端口8080上打开页面

时间:2019-03-05 09:50:22

标签: java selenium testing ui-testing security-testing

我试图在端口8080上使用Java和Selenium打开一个页面。Ive试图使用该页面和:8080,但是该页面不断在另一个端口上打开。我基本上是尝试使用zap,并且将其配置为在端口8080上使用firefox。非常感谢您的帮助。我已经添加了我的测试,并将我的课程添加到了下面的测试中,我认为他的驱动程序部分必须调用其他端口,但我看不到这是怎么回事

测试:

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));
}

十二月课:

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();

}

1 个答案:

答案 0 :(得分:1)

只要有机会尝试使用

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

代替此

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

您正在将端口号添加到游戏目录而不是主机