image source: pixabay
manage() 函数里有 window(), timeOuts(), cookie, ime() 管理函数。
今天就给大家介绍下最常用的window()。
函数 | 描述 |
---|---|
getPosition | 离画面左上角的浏览器位置 返回类型为 Point,它包含 getX(),getY(),moveBy(),move() 附加函数 |
getSize | 返回浏览器大小。是浏览器窗口的大小而不是浏览器内容大小。 返回类型是 Dimension, 它包含 getWidth(),getHeight() 等函数。 |
fullscreen | 设置浏览器全屏模式。同等于F11键。 |
maximize | 设置浏览器最大值。 |
setPosition | 设置浏览器的位置。 同于JS的 window.moveTo()。 |
setSize | 设置浏览器大小。同于 JS的 window.resizeTo()。 |
package com.steem.webatuo;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Keys;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Wait;
import org.openqa.selenium.support.ui.WebDriverWait;
import io.github.bonigarcia.wdm.WebDriverManager;
public class Steemit {
public static void main(String[] args) throws InterruptedException {
WebDriverManager.chromedriver().setup();
WebDriver driver = new ChromeDriver();
driver.get("https://steemit.com");
Point po = driver.manage().window().getPosition();
Point newPo = new Point(po.getX() + 100, po.getY() + 200);
driver.manage().window().setPosition(newPo);
driver.manage().window().getPosition().move(po.getX(), po.getY());
Dimension size = driver.manage().window().getSize();
Dimension newSize = new Dimension(size.getWidth() + 500, size.getHeight() + 500);
driver.manage().window().setSize(newSize);
driver.manage().window().maximize();
driver.manage().window().fullscreen();
Wait<WebDriver> wait = new WebDriverWait(driver, 10);
Thread.sleep(5000);
driver.quit();
}
}
.
.
.
.
[Cookie 😅]
Seleniun java lib version: 3.141.59
@tipu curate
来了😁
来自于 [WhereIn Android] (http://www.wherein.io)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Upvoted 👌 (Mana: 0/15 - need recharge?)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
来啦 多谢👍
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
谢谢~
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit