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)
Upvoted 👌 (Mana: 0/15 - need recharge?)
来啦 多谢👍
!thumbup
【优秀的文章】
请支持他,给他投票,或者设置justyy为见证人代理 恭喜你!您的这篇文章入选 @justyy 今日 (2020-02-06) 榜单 , 回复本条评论24小时内领赏,点赞本评论将支持 @dailychina 并增加将来您的奖赏。 @justyy 是CN区的见证人,。感谢!@justyy的主要贡献:https://steemyy.com
【Good Posts】Congratulations! This post has been selected by @justyy as today's (2020-02-06) , Steem On! Reply to this message in 24 hours to get rewards. Upvote this comment to support the @dailychina and increase your future rewards! ^_^
SteemIt 工具、API接口、机器人和教程
SteemIt Tools, Bots, APIs and Tutorial
If you believe what I am doing, please consider a spare vote voting me here, thank you very much indeed.
more than a year now.@justyy - the author of https://SteemYY.com and I have been a Steem Witness for
谢谢~