本文整理了Java中org.openqa.selenium.WebDriver.manage()
方法的一些代码示例,展示了WebDriver.manage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebDriver.manage()
方法的具体详情如下:
包路径:org.openqa.selenium.WebDriver
类名称:WebDriver
方法名:manage
[英]Gets the Option interface
[中]获取选项接口
代码示例来源:origin: cloudfoundry/uaa
private void doLogout() {
webDriver.get(baseUrl + "/logout.do");
webDriver.manage().deleteAllCookies();
}
}
代码示例来源:origin: cloudfoundry/uaa
private void performLogin(String username) {
webDriver.get(zoneUrl + "/logout.do");
webDriver.manage().deleteAllCookies();
webDriver.get(zoneUrl + "/login");
webDriver.findElement(By.name("username")).sendKeys(username);
webDriver.findElement(By.name("password")).sendKeys(USER_PASSWORD);
webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void checkAccessForTotpPage() throws Exception {
webDriver.get(zoneUrl + "/logout.do");
webDriver.manage().deleteAllCookies();
webDriver.get(zoneUrl + "/login/mfa/register");
assertEquals(zoneUrl + "/login", webDriver.getCurrentUrl());
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testLoginReloadRetainsFormRedirect() {
String redirectUri = "http://expected.com";
webDriver.get(baseUrl + "/oauth/authorize?client_id=test&redirect_uri="+redirectUri);
((JavascriptExecutor)webDriver).executeScript("document.getElementsByName('X-Uaa-Csrf')[0].value=''");
webDriver.manage().deleteCookieNamed("JSESSIONID");
webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
assertThat(webDriver.getCurrentUrl(), Matchers.containsString("/login"));
assertThat(webDriver.findElement(By.name("form_redirect_uri")).getAttribute("value"), Matchers.containsString("redirect_uri="+redirectUri));
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testAccountChooserPopulatesUsernameNotEmailWhenOriginIsUAAorLDAP() throws Exception {
String userUAA = "{\"userId\":\"1\",\"username\":\"userUAA\",\"origin\":\"uaa\",\"email\":\"user@uaa.org\"}";
String userLDAP = "{\"userId\":\"2\",\"username\":\"userLDAP\",\"origin\":\"ldap\",\"email\":\"user@ldap.org\"}";
String userExternal = "{\"userId\":\"3\",\"username\":\"userExternal\",\"origin\":\"external\",\"email\":\"user@external.org\"}";
String zoneUrl = createDiscoveryZone();
webDriver.get(zoneUrl);
webDriver.manage().deleteAllCookies();
JavascriptExecutor js = (JavascriptExecutor) webDriver;
js.executeScript("document.cookie = \"Saved-Account-1=" + URLEncoder.encode(userUAA, StandardCharsets.UTF_8.name()) + ";path=/;domain=testzone3.localhost\"");
js.executeScript("document.cookie = \"Saved-Account-2=" + URLEncoder.encode(userLDAP, StandardCharsets.UTF_8.name()) + ";path=/;domain=testzone3.localhost\"");
js.executeScript("document.cookie = \"Saved-Account-3=" + URLEncoder.encode(userExternal, StandardCharsets.UTF_8.name()) + ";path=/;domain=testzone3.localhost\"");
webDriver.navigate().refresh();
assertEquals(3, webDriver.findElements(By.cssSelector("span.email-address")).size());
webDriver.findElement(By.xpath("//span[contains(text(), 'userUAA')]")).click();
assertEquals("userUAA", webDriver.findElement(By.id("username")).getAttribute("value"));
webDriver.navigate().back();
webDriver.findElement(By.xpath("//span[contains(text(), 'userLDAP')]")).click();
assertEquals("userLDAP", webDriver.findElement(By.id("username")).getAttribute("value"));
webDriver.navigate().back();
webDriver.findElement(By.xpath("//span[contains(text(), 'userExternal')]")).click();
assertEquals("user@external.org", webDriver.findElement(By.id("username")).getAttribute("value"));
webDriver.manage().deleteAllCookies();
}
代码示例来源:origin: stackoverflow.com
public class LaunchParis{
WebDriver localDriver;
//Launch PairsUI
public void LaunchParisUI(WebDriver driver) {
localDriver = driver;
localDriver = new FirefoxDriver();
//localDriver = new ChromeDriver();
localDriver.get("https://xfpqa1uiadm1");
localDriver.manage().window().maximize();
}
代码示例来源:origin: stackoverflow.com
public class Testing_anew {
public static WebDriver driver;
public static void main(String args[]) throws InterruptedException{
driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
public static void testmethod(){
driver.findElement(By.xpath("//some xpath")).click();
}
代码示例来源:origin: stackoverflow.com
public void handle(){
WebDriver driver;
driver=new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://toolsqa.com/automation-practice-switch-windows/");
driver.findElement(By.xpath(".//*[@id='content']/p[4]/button")).click();
ArrayList<String> tabs2 = new ArrayList<String> (driver.getWindowHandles());
driver.switchTo().window(tabs2.get(1));
System.out.println(driver.getTitle());
}
代码示例来源:origin: cloudfoundry/uaa
@Test
public void testBannerBackgroundIsHiddenIfNoTextOrImage() {
String zoneId = "testzone3";
RestTemplate identityClient = IntegrationTestUtils.getClientCredentialsTemplate(
IntegrationTestUtils.getClientCredentialsResource(baseUrl, new String[]{"zones.write", "zones.read", "scim.zones"}, "identity", "identitysecret")
);
IdentityZoneConfiguration config = new IdentityZoneConfiguration();
config.setIdpDiscoveryEnabled(true);
Banner banner = new Banner();
banner.setLink("http://example.com");
banner.setBackgroundColor("#444");
banner.setTextColor("#111");
config.setBranding(new BrandingInformation());
config.getBranding().setBanner(banner);
IntegrationTestUtils.createZoneOrUpdateSubdomain(identityClient, baseUrl, zoneId, zoneId, config);
String zoneUrl = baseUrl.replace("localhost",zoneId+".localhost");
webDriver.get(zoneUrl);
webDriver.manage().deleteAllCookies();
webDriver.navigate().refresh();
assertEquals(0, webDriver.findElements(By.cssSelector(".banner-header")).size());
}
代码示例来源:origin: stackoverflow.com
WebDriver myTestDriver = new FirefoxDriver();
myTestDriver.get("...blablabla....");
myTestDriver.manage().window().maximize();
myTestDriver.findElement(By.xpath("//input[@value = 'alert']")).click();
myTestDriver.findElement(By.xpath("//input[@value = 'prompt']")).click();
myTestDriver.findElement(By.xpath("//input[@value = 'prompt']")).click();
代码示例来源:origin: cloudfoundry/uaa
private void doLogout(String zoneUrl) {
for (String url : Arrays.asList("http://simplesamlphp.cfapps.io/module.php/core/authenticate.php?as=example-userpass&logout", baseUrl + "/logout.do", zoneUrl + "/logout.do")) {
webDriver.get(url);
webDriver.manage().deleteAllCookies();
}
}
代码示例来源:origin: code4craft/webmagic
webDriver.get(request.getUrl());
try {
Thread.sleep(sleepTime);
e.printStackTrace();
WebDriver.Options manage = webDriver.manage();
Site site = task.getSite();
if (site.getCookies() != null) {
WebElement webElement = webDriver.findElement(By.xpath("/html"));
String content = webElement.getAttribute("outerHTML");
Page page = new Page();
代码示例来源:origin: cloudfoundry/uaa
public void performLogin(String idpZoneId, String idpZoneUserEmail, String idpZoneUrl, IdentityZone spZone, String spZoneUrl, SamlIdentityProviderDefinition samlIdentityProviderDefinition) {
webDriver.get(baseUrl + "/logout.do");
webDriver.get(spZoneUrl + "/logout.do");
webDriver.get(idpZoneUrl+ "/logout.do");
webDriver.get(spZoneUrl + "/");
assertEquals(spZone.getName(), webDriver.getTitle());
Cookie beforeLogin = webDriver.manage().getCookieNamed("JSESSIONID");
assertNotNull(beforeLogin);
assertNotNull(beforeLogin.getValue());
webDriver.findElement(By.xpath("//h1[contains(text(), 'Welcome to The Twiglet Zone[" + idpZoneId + "]!')]"));
webDriver.findElement(By.name("username")).clear();
webDriver.findElement(By.name("username")).sendKeys(idpZoneUserEmail);
webDriver.findElement(By.name("password")).sendKeys("secr3T");
webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), containsString("Where to?"));
Cookie afterLogin = webDriver.manage().getCookieNamed("JSESSIONID");
assertNotNull(afterLogin);
assertNotNull(afterLogin.getValue());
代码示例来源:origin: stackoverflow.com
public class Tests_Steps {
WebDriver driver = null;
@Given("^User is on the Home Page$")
public void user_is_on_the_Home_Page() throws Throwable {
driver=new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
driver.get("http://www.gmail.com/login");
}
------------
------------
}
代码示例来源:origin: stackoverflow.com
WebDriver driver = new FirefoxDriver();
String baseUrl = "http://www.google.co.in/";
selenium = new WebDriverBackedSelenium(driver, baseUrl);
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
driver.findElement(By.xpath("//div[@id=':jb']/div[@class='z0']/div")).click(); // Compose
selenium.type("//div[@class='wO nr l1']//textarea[@name='to']", "vikramn@gmail.com"); // For To
selenium.type("//div[@class='aoD az6']//input[@name='subjectbox']", "Wanted to SAY HI"); // For Subject
selenium.type("//div[@class='Ar Au']/div[@class='Am Al editable LW-avf']", "Hi Vikram");// For Message body
selenium.click("//div[@class='J-J5-Ji']/div[@class='T-I J-J5-Ji aoO T-I-atl L3']"); //send
代码示例来源:origin: cloudfoundry/uaa
private void login(String zoneUrl, String userName, String password) {
webDriver.get(zoneUrl + "/logout.do");
webDriver.get(zoneUrl + "/");
Cookie beforeLogin = webDriver.manage().getCookieNamed("JSESSIONID");
assertNotNull(beforeLogin);
assertNotNull(beforeLogin.getValue());
webDriver.findElement(By.linkText("My OIDC Provider")).click();
Assert.assertThat(webDriver.getCurrentUrl(), containsString(baseUrl));
webDriver.findElement(By.name("username")).sendKeys(userName);
webDriver.findElement(By.name("password")).sendKeys(password);
webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
Assert.assertThat(webDriver.getCurrentUrl(), containsString(zoneUrl));
assertThat(webDriver.findElement(By.cssSelector("h1")).getText(), containsString("Where to?"));
Cookie afterLogin = webDriver.manage().getCookieNamed("JSESSIONID");
assertNotNull(afterLogin);
assertNotNull(afterLogin.getValue());
assertNotEquals(beforeLogin.getValue(), afterLogin.getValue());
}
代码示例来源:origin: cloudfoundry/uaa
public static List<String> getAccountChooserCookies(String baseUrl, WebDriver webDriver) {
webDriver.get(baseUrl + "/logout.do");
webDriver.get(baseUrl + "/login");
return webDriver.manage().getCookies().stream().map(Cookie::getName).collect(Collectors.toList());
}
代码示例来源:origin: cloudfoundry/uaa
private void doLogin() throws UnsupportedEncodingException {
webDriver.get(baseUrl + "/login");
webDriver.findElement(By.name("username")).sendKeys(testAccounts.getUserName());
webDriver.findElement(By.name("password")).sendKeys(testAccounts.getPassword());
webDriver.findElement(By.xpath("//input[@value='Sign in']")).click();
Cookie currentUserCookie = webDriver.manage().getCookieNamed("Current-User");
CurrentUserInformation currentUserInformation = JsonUtils.readValue(URLDecoder.decode(currentUserCookie.getValue(), "UTF-8"), CurrentUserInformation.class);
String userId = currentUserInformation.getUserId();
testPage = "file://" + System.getProperty("user.dir") + "/src/test/resources/session_frame_test.html#" + userId;
}
代码示例来源:origin: stackoverflow.com
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://www.example.com");
HomePage homePage = new HomePage(driver);
homePage.clickSampleElement();
// do stuff that changes the page and makes the element stale
homePage.clickSampleElement();
代码示例来源:origin: stackoverflow.com
WebDriver driver = new FirefoxDriver();
String baseUrl = "http://www.google.co.in/";
selenium = new WebDriverBackedSelenium(driver, baseUrl);
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
driver.findElement(By.xpath("//div[@id=':jb']/div[@class='z0']/div")).click(); // Compose
selenium.type("//div[@class='wO nr l1']//textarea[@name='to']", "vikramn@gmail.com"); // For To
selenium.type("//div[@class='aoD az6']//input[@name='subjectbox']", "Wanted to SAY HI"); // For Subject
selenium.type("//div[@class='Ar Au']/div[@class='Am Al editable LW-avf']", "Hi Vikram");// For Message body
selenium.click("//div[@class='J-J5-Ji']/div[@class='T-I J-J5-Ji aoO T-I-atl L3']"); //send
内容来源于网络,如有侵权,请联系作者删除!