Skip to content

Commit

Permalink
Merge pull request #232 from ChaseCares/remove_wikipedia_links
Browse files Browse the repository at this point in the history
Migrate wait_for_nav test to use local files
  • Loading branch information
jonhoo authored Aug 27, 2023
2 parents 5f794cf + f029f38 commit 18b52fe
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 41 deletions.
39 changes: 39 additions & 0 deletions tests/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use futures_util::TryFutureExt;
use hyper::Method;
use serial_test::serial;
use std::time::Duration;
use url::Url;
use webdriver::command::WebDriverCommand;

mod common;
Expand Down Expand Up @@ -649,6 +650,32 @@ async fn simple_wait_test(c: Client, _port: u16) -> Result<(), error::CmdError>
c.close().await
}

async fn wait_for_navigation_test(c: Client, _port: u16) -> Result<(), error::CmdError> {
let mut path = std::env::current_dir().unwrap();
path.push("tests/test_html/redirect_test.html");

let path_string = format!("file://{}", path.to_str().unwrap());
let file_url_str = path_string.as_str();
let mut url = Url::parse(file_url_str)?;

c.goto(url.as_str()).await?;

#[allow(deprecated)]
loop {
let wait_for = c.wait_for_navigation(Some(url)).await;
assert!(wait_for.is_ok());
url = c.current_url().await?;
if url.as_str() == "about:blank" {
// try again
continue;
}
assert!(url.to_string().ends_with("sample_page.html"));
break;
}

c.close().await
}

mod firefox {
use super::*;
#[test]
Expand Down Expand Up @@ -848,6 +875,12 @@ mod firefox {
fn it_simple_waits() {
local_tester!(simple_wait_test, "firefox");
}

#[serial]
#[test]
fn it_waits_for_navigation() {
local_tester!(wait_for_navigation_test, "firefox");
}
}

mod chrome {
Expand Down Expand Up @@ -1016,4 +1049,10 @@ mod chrome {
fn it_simple_waits() {
local_tester!(simple_wait_test, "chrome");
}

#[serial]
#[test]
fn it_waits_for_navigation() {
local_tester!(wait_for_navigation_test, "chrome");
}
}
39 changes: 0 additions & 39 deletions tests/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,9 @@
use cookie::SameSite;
use fantoccini::{error, Client};
use serial_test::serial;
use url::Url;

mod common;

async fn wait_for_navigation_test(c: Client) -> Result<(), error::CmdError> {
let mut path = std::env::current_dir().unwrap();
path.push("tests/redirect_test.html");

let path_string = format!("file://{}", path.to_str().unwrap());
let file_url_str = path_string.as_str();
let mut url = Url::parse(file_url_str)?;

c.goto(url.as_str()).await?;

#[allow(deprecated)]
loop {
let wait_for = c.wait_for_navigation(Some(url)).await;
assert!(wait_for.is_ok());
url = c.current_url().await?;
if url.as_str() == "about:blank" {
// try again
continue;
}
assert_eq!(url.as_str(), "https://www.wikipedia.org/");
break;
}

c.close().await
}

// Verifies that basic cookie handling works
async fn handle_cookies_test(c: Client) -> Result<(), error::CmdError> {
c.goto("https://www.wikipedia.org/").await?;
Expand Down Expand Up @@ -76,12 +49,6 @@ async fn handle_cookies_test(c: Client) -> Result<(), error::CmdError> {
mod chrome {
use super::*;

#[serial]
#[test]
fn it_waits_for_navigation() {
tester!(wait_for_navigation_test, "chrome");
}

#[serial]
#[test]
fn it_handles_cookies() {
Expand All @@ -92,12 +59,6 @@ mod chrome {
mod firefox {
use super::*;

#[serial]
#[test]
fn it_waits_for_navigation() {
tester!(wait_for_navigation_test, "firefox");
}

#[serial]
#[test]
fn it_handles_cookies() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" http-equiv="refresh" content="5;url=https://www.wikipedia.org">
<meta charset="UTF-8" http-equiv="refresh" content="5;url=sample_page.html">
<title>This Page will Redirect</title>
</head>
<body>
This page will redirect to https://wikipedia.org
</body>
</html>
</html>

0 comments on commit 18b52fe

Please sign in to comment.