Skip to content

Commit 4eb21cf

Browse files
author
Wusi
committed
server
1 parent b26e131 commit 4eb21cf

File tree

2 files changed

+28
-29
lines changed

2 files changed

+28
-29
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.idea
22
target
3-
*.kar
3+
*.jar
44
geckodriver
55
*.iml

rust-selenium-email-testing/tests/selenium_email_sign_up.rs

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,37 @@ mod tests {
88
use tokio;
99
use mailslurp::apis::inbox_controller_api::SendEmailAndConfirmParams;
1010
use mailslurp::apis::wait_for_controller_api;
11+
use std::time::Duration;
12+
use reqwest::Client;
13+
use thirtyfour::http::reqwest_async::ReqwestDriverAsync;
14+
use thirtyfour::GenericWebDriver;
15+
use color_eyre::Report;
16+
17+
const TIMEOUT: Duration = Duration::from_millis(60_000);
1118

1219
#[tokio::test]
13-
async fn my_test() -> color_eyre::Result<()> {
20+
async fn run_test() -> color_eyre::Result<()> {
1421
// use color-eyre for better result reports
1522
color_eyre::install()?;
1623

17-
let client = reqwest::Client::new();
24+
// setup driver (selenium with geckodriver should be running)
25+
let caps = DesiredCapabilities::firefox();
26+
let driver: GenericWebDriver<ReqwestDriverAsync> = WebDriver::new_with_timeout(
27+
"http://localhost:4444/wd/hub",
28+
&caps,
29+
Some(TIMEOUT)
30+
).await?;
31+
32+
33+
// allow a long timeout to wait for emails to arrive
34+
let client: Client = reqwest::ClientBuilder::new()
35+
.timeout(TIMEOUT)
36+
.connect_timeout(TIMEOUT)
37+
.build()?;
38+
1839
// read mailslurp api key from environment variable
19-
let api_key = env::var("API_KEY").ok().unwrap();
40+
let api_key: String = env::var("API_KEY")?;
41+
2042
// configure mailslurp with base path, api key, and reqwest client
2143
let configuration = configuration::Configuration {
2244
// required fields
@@ -48,31 +70,8 @@ mod tests {
4870
let inbox = inbox_controller_api::create_inbox(&configuration, create_inbox_params).await.ok().unwrap();
4971
assert!(inbox.email_address.unwrap().contains("@mailslurp"));
5072

51-
52-
// // setup driver (selenium with geckodriver should be running)
53-
// let caps = DesiredCapabilities::firefox();
54-
// let driver = WebDriver::new("http://localhost:4444/wd/hub", &caps).await?;
55-
//
56-
// // load playground application
57-
// driver.get("https://playground.mailslurp.com").await?;
58-
// let elem_form = driver.find_element(By::Id("search-form")).await?;
59-
//
60-
// // Find element from element.
61-
// let elem_text = elem_form.find_element(By::Id("searchInput")).await?;
62-
//
63-
// // Type in the search terms.
64-
// elem_text.send_keys("selenium").await?;
65-
//
66-
// // Click the search button.
67-
// let elem_button = elem_form
68-
// .find_element(By::Css("button[type='submit']"))
69-
// .await?;
70-
// elem_button.click().await?;
71-
//
72-
// // Look for header to implicitly wait for the page to load.
73-
// driver.find_element(By::ClassName("firstHeading")).await?;
74-
// assert_eq!(driver.title().await?, "Selenium - Wikipedia");
75-
//
73+
// load playground application
74+
driver.get("https://playground.mailslurp.com").await?;
7675
Ok(())
7776
}
7877
}

0 commit comments

Comments
 (0)