![redsjavahouse1591357_1280.jpg](https://steemitimages.com/0x0/https://files.steempeak.com/file/steempeak/june0620/DKldjbG3-reds-java-house-1591357_1280.jpg) image source: [pixabay](https://pixabay.com/photos/red-s-java-house-eatery-cafe-1591357/0) --- 今天让我们学习selenium 的Timeouts。 它属于manage()函数内并提供如下三个函数。 ![image.png](https://steemitimages.com/0x0/https://files.steempeak.com/file/steempeak/june0620/LA2B3HgX-image.png) ##### 1. implicitlyWait 这孩纸在 Webdriver 期已经解释过。 [[JAVA 6#] [Web Automation 6#] Controlling STEEMIT web pages with Selenium #4 WebDriverWait [KR]](https://steemit.com/kr/@june0620/java-6-web-automation-6-controlling-steemit-web-pages-with-selenium-4-webdriverwait-kr) ##### 2. pageLoadTimeouts 如其名就是等到页面全部加载, 如超过设定的时间就抛出 TimeOutException。 参数由 time和时间单位组成, 设置 time为负数就一直等待。 👇 ``` driver.manage().timeouts().pageLoadTimeout(-1, TimeUnit.SECONDS); ``` **次函数值适用与 Selenium的 `driver.get()`及 `driver.navigate().to()`。即对点击页面元素无效果。** 用于性能测试或者IE浏览器测试时有效果。 ##### 3. setScriptTimeout 可以设置非同步超时时间,超时则抛出 TimeOutException。 次函数值影响到 executeAsyncScript函数,不影响 executeScript 函数。 再一个,用 executeAsyncScript时必须设置 setScriptTimeout。因为 setScriptTimeout 默认值是0,但是javascript执行时间一般超过零。 --- ``` package com.steem.webatuo; import java.util.concurrent.TimeUnit; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; 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"); driver.manage().timeouts().setScriptTimeout(20, TimeUnit.SECONDS); driver.manage().timeouts().pageLoadTimeout(4, TimeUnit.SECONDS); driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS); Wait<WebDriver> wait = new WebDriverWait(driver, 10); /** * Some actions */ Thread.sleep(5000); driver.quit(); } } ``` . . . . [Cookie 😅] Seleniun java lib version: 3.141.59
post_id | 84,247,038 |
---|---|
author | june0620 |
permlink | java-9-web-automation-9-controlling-steemit-web-pages-with-selenium-7-timeouts-cn |
category | sct |
json_metadata | {"tags":["sct","sct-cn","sct-freeboard","cn","cn-stem","mini","steemstem","zzan","palnet","java"],"image":["https:\/\/steemitimages.com\/0x0\/https:\/\/files.steempeak.com\/file\/steempeak\/june0620\/DKldjbG3-reds-java-house-1591357_1280.jpg","https:\/\/steemitimages.com\/0x0\/https:\/\/files.steempeak.com\/file\/steempeak\/june0620\/LA2B3HgX-image.png"],"links":["https:\/\/pixabay.com\/photos\/red-s-java-house-eatery-cafe-1591357\/0","https:\/\/steemit.com\/kr\/@june0620\/java-6-web-automation-6-controlling-steemit-web-pages-with-selenium-4-webdriverwait-kr"],"app":"steemcoinpan\/0.1","format":"markdown","canonical_url":"https:\/\/www.steemcoinpan.com\/@june0620\/java-9-web-automation-9-controlling-steemit-web-pages-with-selenium-7-timeouts-cn"} |
created | 2020-02-10 13:42:48 |
last_update | 2020-02-10 13:42:48 |
depth | 0 |
children | 7 |
net_rshares | 30,382,276,472,899 |
last_payout | 2020-02-17 13:42:48 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 5.606 SBD |
curator_payout_value | 4.572 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 2,099 |
author_reputation | 219,336,602,045,061 |
root_title | "[JAVA #9] [Web Automation #9] Controlling STEEMIT web pages with Selenium #7 Timeouts [CN]" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
mangou007 | 0 | 7,610,693,694 | 5.1% | ||
gerber | 0 | 107,094,690,573 | 2% | ||
daan | 0 | 131,557,644,545 | 2% | ||
exyle | 0 | 362,275,468,945 | 5% | ||
magicmonk | 0 | 1,040,714,222,937 | 100% | ||
bert0 | 0 | 22,130,822,309 | 5.1% | ||
tumutanzi | 0 | 5,081,398,593 | 50% | ||
oldstone | 0 | 732,870,679,150 | 30% | ||
petrvl | 0 | 10,643,519,596 | 1.5% | ||
jack8831 | 0 | 16,348,250,203 | 25% | ||
dylanhobalart | 0 | 128,940,781,344 | 92% | ||
coldhair | 0 | 892,445,338 | 50% | ||
imperfect-one | 0 | 799,895,802 | 5% | ||
centering | 0 | 866,711,593,971 | 46% | ||
mys | 0 | 9,919,657,314 | 5% | ||
rycharde | 0 | 732,469,571 | 1.8% | ||
allsale | 0 | 382,112,833,277 | 100% | ||
virus707 | 0 | 3,038,580,136,600 | 19% | ||
shenchensucc | 0 | 155,570,427,456 | 30% | ||
ew-and-patterns | 0 | 159,164,459,891 | 8% | ||
techken | 0 | 0 | 0.14% | ||
whd | 0 | 5,905,849,893 | 5% | ||
khaiyoui | 0 | 983,143,494,063 | 25% | ||
hope-on-fire | 0 | 275,338,262,897 | 95% | ||
syskwl | 0 | 134,233,394,383 | 30% | ||
jesus.christ | 0 | 465,469,040 | 5% | ||
ilovemylife | 0 | 685,764,449,625 | 31.25% | ||
tipu | 0 | 3,931,045,894,305 | 5% | ||
accelerator | 0 | 30,528,123,940 | 1.8% | ||
june0620 | 0 | 1,116,850,324,281 | 100% | ||
xiaoshancun | 0 | 20,643,250,112 | 100% | ||
minloulou | 0 | 2,322,050,090 | 10% | ||
flamingirl | 0 | 61,285,988,887 | 5.1% | ||
lindalex | 0 | 580,290,767 | 50% | ||
blockbrothers | 0 | 66,675,927,280 | 2.5% | ||
new-world-steem | 0 | 25,497,826,612 | 94% | ||
cnbuddy | 0 | 1,903,587,536,693 | 100% | ||
stupid | 0 | 622,528,175 | 40% | ||
mehta | 0 | 67,917,676,831 | 40% | ||
suhunter | 0 | 961,902,227 | 50% | ||
udabeu | 0 | 12,560,250,901 | 40% | ||
marsswim | 0 | 90,726,894,322 | 51% | ||
cadawg | 0 | 6,258,040,063 | 1.4% | ||
maikuraki | 0 | 1,104,532,797 | 19% | ||
fego | 0 | 5,445,368,665 | 3.5% | ||
earlmonk | 0 | 577,239,020 | 5% | ||
bonzopoe | 0 | 7,893,949,432 | 50% | ||
beleg | 0 | 2,142,445,395 | 5% | ||
bestboom | 0 | 15,850,052,315 | 2% | ||
stmdev | 0 | 83,641,570 | 1% | ||
lucky2015 | 0 | 370,507,811,512 | 100% | ||
gghite | 0 | 459,318,907,591 | 65% | ||
tresor | 0 | 14,306,733,149 | 5.1% | ||
jaydih | 0 | 437,977,121,302 | 11% | ||
andrewma | 0 | 10,317,725,386 | 50% | ||
kimseun | 0 | 70,177,562,435 | 11% | ||
wisdomandjustice | 0 | 759,972,895,634 | 30% | ||
pladozero | 0 | 48,434,854,482 | 10% | ||
nateaguila | 0 | 210,247,014,918 | 8% | ||
ravenkim | 0 | 8,549,326,722 | 100% | ||
robertyan | 0 | 11,285,141,839 | 100% | ||
kanadaramagi123 | 0 | 47,780,040,095 | 11% | ||
loveecho | 0 | 84,355,537,651 | 11% | ||
wanggang | 0 | 151,003,852,937 | 20% | ||
mightypanda | 0 | 2,695,315,096 | 3.5% | ||
pagliozzo | 0 | 17,928,129,609 | 20% | ||
angelslake | 0 | 18,186,098,457 | 11% | ||
harkar | 0 | 85,399,071,891 | 20% | ||
dlike | 0 | 205,391,096,838 | 2.85% | ||
triptolemus | 0 | 7,894,474,878 | 2% | ||
melaniewang | 0 | 8,135,928,983 | 50% | ||
mysia | 0 | 2,296,853,984 | 100% | ||
wordit | 0 | 17,588,481,583 | 11% | ||
changxiu | 0 | 4,858,121,423 | 50% | ||
sj-jeong | 0 | 575,304,242,126 | 11% | ||
wondumyungga | 0 | 38,893,224,157 | 11% | ||
laissez-faire | 0 | 96,250,138 | 100% | ||
pet.society | 0 | 16,390,827,987 | 5% | ||
aquawink | 0 | 44,380,067,130 | 11% | ||
cherryzz | 0 | 205,321,369,171 | 50% | ||
djusti | 0 | 1,858,360,716,447 | 100% | ||
memeteca | 0 | 1,428,639,351 | 5.1% | ||
ringit | 0 | 29,902,847,594 | 11% | ||
coreabeforekorea | 0 | 351,200,132,584 | 11% | ||
general.guy | 0 | 574,886,190 | 5% | ||
talkative-bk | 0 | 451,973,141,511 | 11% | ||
nineteensixteen | 0 | 627,218,088,231 | 100% | ||
wherein | 0 | 2,055,514,902,368 | 48% | ||
sindong | 0 | 608,725,711,688 | 80% | ||
edgarare1 | 0 | 924,455,888 | 2.5% | ||
steemfriends | 0 | 3,798,115,877 | 100% | ||
cyberrn | 0 | 747,769,034,456 | 17% | ||
primeradue | 0 | 1,931,768,130 | 2% | ||
mia-cc | 0 | 565,963,678 | 5% | ||
tina3721 | 0 | 4,865,573,237 | 50% | ||
andyhsia | 0 | 6,566,370,541 | 100% | ||
minigame | 0 | 1,347,860,095,973 | 3.2% | ||
whatdidshewear | 0 | 89,372,299,537 | 11% | ||
kr-fund | 0 | 3,372,382,393 | 25% | ||
jjm13 | 0 | 17,845,064,360 | 19% | ||
sjgod4018 | 0 | 72,980,963,991 | 11% | ||
mustard-seed | 0 | 35,512,894,388 | 11% | ||
koei | 0 | 1,827,340,168 | 50% | ||
fsm-liquid | 0 | 13,479,309,200 | 5% | ||
anthos | 0 | 783,805,976 | 20% | ||
zzan.co3 | 0 | 467,498,068 | 100% | ||
triplea.bot | 0 | 2,118,944,212 | 5% | ||
steem.leo | 0 | 58,026,704,963 | 1.9% | ||
cn-zzang | 0 | 1,705,940,071 | 5% | ||
leo.voter | 0 | 165,844,748,529 | 1.56% | ||
cn-sct | 0 | 1,937,316,208 | 2% | ||
cn-pal | 0 | 556,088,971 | 5% | ||
perrymine | 0 | 903,550,249 | 11% | ||
freddio.sport | 0 | 44,603,981,814 | 15% | ||
freegon.sct | 0 | 16,369,458,473 | 100% | ||
mapxv | 0 | 12,511,584,401 | 1.44% | ||
tokenindustry | 0 | 1,106,845,729 | 39.99% | ||
sct.krwp | 0 | 87,671,610,659 | 0.13% | ||
leo.syndication | 0 | 907,967,042 | 2% | ||
maxuva | 0 | 776,903,960 | 1.8% | ||
maxuvb | 0 | 1,134,328,675 | 1.8% | ||
maxuvc | 0 | 1,140,283,794 | 1.8% | ||
maxuvd | 0 | 778,232,334 | 1.8% | ||
maxuve | 0 | 6,310,244,872 | 1.44% | ||
sct.curator | 0 | 18,808,442,471 | 22.72% | ||
therealyme | 0 | 11,488,417,399 | 4.5% | ||
jaykayw | 0 | 24,346,863,358 | 11% | ||
taverngames | 0 | 20,237,777,688 | 100% | ||
cnbuddy-reward | 0 | 924,538,758,284 | 100% | ||
morningcare | 0 | 20,697,351,197 | 30% | ||
real3earch | 0 | 7,602,060,607 | 100% | ||
unpopular | 0 | 30,110,530,646 | 40% | ||
kryptoformator | 0 | 640,257,327 | 0.75% | ||
reward.tier2 | 0 | 1,989,361,303 | 100% | ||
bilpcoinpower | 0 | 202,917,112 | 10% | ||
kgsupport | 0 | 10,913,381,085 | 9.5% | ||
vreislo | 0 | -5,002,318 | -10% |
@tipu curate 这下巧了😅 !shop Posted using [Partiko Android](https://partiko.app/referral/annepink)
post_id | 84,247,128 |
---|---|
author | annepink |
permlink | annepink-re-june0620-java-9-web-automation-9-controlling-steemit-web-pages-with-selenium-7-timeouts-cn-20200210t134653877z |
category | sct |
json_metadata | {"app":"partiko","client":"android"} |
created | 2020-02-10 13:46:54 |
last_update | 2020-02-10 13:46:54 |
depth | 1 |
children | 2 |
net_rshares | 0 |
last_payout | 2020-02-17 13:46:54 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 96 |
author_reputation | 160,119,580,804,298 |
root_title | "[JAVA #9] [Web Automation #9] Controlling STEEMIT web pages with Selenium #7 Timeouts [CN]" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
<a href="https://tipu.online/curator?annepink" target="_blank">Upvoted 👌</a> (Mana: 5/15 - <a href="https://steempeak.com/steem/@tipu/tipu-curate-project-update-recharging-curation-mana" target="_blank">need recharge</a>?)
post_id | 84,247,133 |
---|---|
author | tipu |
permlink | re-annepink-re-june0620-java-9-web-automation-9-controlling-steemit-web-pages-with-selenium-7-timeouts-cn-20200210t134653877z-20200210t134712 |
category | sct |
json_metadata | {} |
created | 2020-02-10 13:47:09 |
last_update | 2020-02-10 13:47:09 |
depth | 2 |
children | 0 |
net_rshares | 0 |
last_payout | 2020-02-17 13:47:09 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 230 |
author_reputation | 55,804,171,747,699 |
root_title | "[JAVA #9] [Web Automation #9] Controlling STEEMIT web pages with Selenium #7 Timeouts [CN]" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
哈哈😄 谢谢~ 🤩
post_id | 84,247,613 | ||||||
---|---|---|---|---|---|---|---|
author | june0620 | ||||||
permlink | re-annepink-2020210t2362516z | ||||||
category | sct | ||||||
json_metadata | {"tags":["esteem"],"app":"esteem\/2.2.4-mobile","format":"markdown+html","community":"hive-125125"} | ||||||
created | 2020-02-10 14:06:24 | ||||||
last_update | 2020-02-10 14:06:24 | ||||||
depth | 2 | ||||||
children | 0 | ||||||
net_rshares | 0 | ||||||
last_payout | 2020-02-17 14:06:24 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 0.000 SBD | ||||||
curator_payout_value | 0.000 SBD | ||||||
pending_payout_value | 0.000 SBD | ||||||
promoted | 0.000 SBD | ||||||
body_length | 9 | ||||||
author_reputation | 219,336,602,045,061 | ||||||
root_title | "[JAVA #9] [Web Automation #9] Controlling STEEMIT web pages with Selenium #7 Timeouts [CN]" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 SBD | ||||||
percent_steem_dollars | 10,000 |
你好鸭,june0620! @annepink给您叫了一份外卖! 由 @xiaoyuanwmm 村凤 迎着海啸 undefined 给您送来 **巧克力蛋糕** <br> ![](https://steemitimages.com/0x0/https://cdn.steemitimages.com/DQma1eqtjk48SZHV2gjMPrJKVEDrXgYMD9MkyY58YSwP6LT/JPEG_20180525_134924_5872129153971841949.jpg) 吃饱了吗?跟我猜拳吧! **石头,剪刀,布~** 如果您对我的服务满意,请不要吝啬您的点赞~ @onepagex
post_id | 84,247,132 |
---|---|
author | teamcn-shop |
permlink | annepink-re-june0620-java-9-web-automation-9-controlling-steemit-web-pages-with-selenium-7-timeouts-cn-20200210t134653877z |
category | sct |
json_metadata | "{"app":"teamcn-shop bot\/1.0"}" |
created | 2020-02-10 13:47:06 |
last_update | 2020-02-10 13:47:06 |
depth | 1 |
children | 0 |
net_rshares | 0 |
last_payout | 2020-02-17 13:47:06 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 304 |
author_reputation | 66,408,278,506,348 |
root_title | "[JAVA #9] [Web Automation #9] Controlling STEEMIT web pages with Selenium #7 Timeouts [CN]" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
来啪了
post_id | 84,247,546 |
---|---|
author | sunai |
permlink | q5hoeg |
category | sct |
json_metadata | {"app":"busy\/2.5.4"} |
created | 2020-02-10 14:03:54 |
last_update | 2020-02-10 14:03:54 |
depth | 1 |
children | 1 |
net_rshares | 0 |
last_payout | 2020-02-17 14:03:54 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 3 |
author_reputation | 82,963,848,333,719 |
root_title | "[JAVA #9] [Web Automation #9] Controlling STEEMIT web pages with Selenium #7 Timeouts [CN]" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
多谢🤩😀
post_id | 84,247,833 | ||||||
---|---|---|---|---|---|---|---|
author | june0620 | ||||||
permlink | re-sunai-2020210t23160377z | ||||||
category | sct | ||||||
json_metadata | {"tags":["esteem"],"app":"esteem\/2.2.4-mobile","format":"markdown+html","community":"hive-125125"} | ||||||
created | 2020-02-10 14:16:00 | ||||||
last_update | 2020-02-10 14:16:00 | ||||||
depth | 2 | ||||||
children | 0 | ||||||
net_rshares | 0 | ||||||
last_payout | 2020-02-17 14:16:00 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 0.000 SBD | ||||||
curator_payout_value | 0.000 SBD | ||||||
pending_payout_value | 0.000 SBD | ||||||
promoted | 0.000 SBD | ||||||
body_length | 4 | ||||||
author_reputation | 219,336,602,045,061 | ||||||
root_title | "[JAVA #9] [Web Automation #9] Controlling STEEMIT web pages with Selenium #7 Timeouts [CN]" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 SBD | ||||||
percent_steem_dollars | 10,000 |