forked from saucelabs-training/demo-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WindowsAuthentication.java
66 lines (53 loc) · 2.01 KB
/
WindowsAuthentication.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package com.saucedemo.selenium.junit4;
import com.saucelabs.saucebindings.Prerun;
import com.saucelabs.saucebindings.SaucePlatform;
import com.saucelabs.saucebindings.SauceSession;
import com.saucelabs.saucebindings.options.SauceOptions;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* Tests for Basic Authentication.
*/
public class WindowsAuthentication {
private SauceSession session;
private SauceOptions sauceOptions;
@After
public void tearDown() {
session.stop(true);
}
@Test
public void basicAuthTest() {
sauceOptions = new SauceOptions();
sauceOptions.setPlatformName(SaucePlatform.WINDOWS_10);
session = new SauceSession(sauceOptions);
RemoteWebDriver driver = session.start();
driver.get("http://admin:admin@the-internet.herokuapp.com/basic_auth");
WebElement content = driver.findElement(By.id("content"));
assertTrue(content.isDisplayed());
}
@Test
@Ignore("doesn't work")
public void autoItScriptTest() {
//Good AutoIt docs: https://support.saucelabs.com/hc/en-us/articles/360049978374-Sample-AutoIT-Example-to-Handle-Integrated-Windows-Authentication-Dialog-IWA-
sauceOptions = new SauceOptions();
Map<Prerun, Object> prerun = new HashMap<>();
prerun.put(Prerun.EXECUTABLE, "sauce-storage:login.zip");
prerun.put(Prerun.ARGS, "--silent");
prerun.put(Prerun.ARGS, "-a");
prerun.put(Prerun.ARGS, "-q");
prerun.put(Prerun.BACKGROUND, true);
sauceOptions.sauce().setPrerun(prerun);
session = new SauceSession(sauceOptions);
RemoteWebDriver driver = session.start();
driver.get("http://the-internet.herokuapp.com/basic_auth");
fail();
}
}