~~~ WebDriver driver = new FirefoxDriver(); driver.manage().window().maximize(); driver.get("URL"); String newWindow = driver.getWindowHandle(); driver.findElement(By.cssSelector(“body”)).sendKeys(Keys.CONTROL+”t”); driver.get("Second URL"); //Perform whatever actions you want done on the secondary tab, let’s pretend we’re logging in somewhere driver.findElementById(“ID”).sendKeys(“username”); driver.findElementById(“ID”).sendKeys(“password”); driver.findElementById(“submit”).click(); driver.switchTo().window(mainWindow); //Perform whatever actions you want done on the main tab, we’ll click a button driver.findElementById(“button”).click(); # Close current tab driver.findElement(By.cssSelector(“body”)).sendKeys(Keys.CONTROL + 'w'); driver.close(); ~~~
author | python-dev |
---|---|
permlink | selenium-managing-multiple-tabs |
category | python-dev |
json_metadata | {"tags":["python-dev"],"app":"steemit/0.2","format":"markdown"} |
created | 2020-03-13 12:39:57 |
last_update | 2020-03-13 12:39:57 |
depth | 0 |
children | 1 |
last_payout | 2020-03-20 12:39:57 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.426 HBD |
curator_payout_value | 0.026 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 779 |
author_reputation | 5,457,648,648,750 |
root_title | "Selenium Managing Multiple Tabs" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 96,322,169 |
net_rshares | 4,294,102,428,330 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
anomaly | 0 | 147,962,124 | 1% | ||
xiguang | 0 | 1,602,717,608,344 | 100% | ||
ctime | 0 | 199,256,947,982 | 2% | ||
ctl001 | 0 | 545,951,213 | 100% | ||
crypto.income | 0 | 2,491,433,958,667 | 100% |
this is a good instruct ion, so it can be used to switch and automate different web pages
author | xiguang |
---|---|
permlink | q7bajo |
category | python-dev |
json_metadata | {"app":"steemit/0.2"} |
created | 2020-03-17 00:26:09 |
last_update | 2020-03-17 00:26:09 |
depth | 1 |
children | 0 |
last_payout | 2020-03-24 00:26:09 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.467 HBD |
curator_payout_value | 0.467 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 89 |
author_reputation | 17,083,626,025,549 |
root_title | "Selenium Managing Multiple Tabs" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 0 |
post_id | 96,420,947 |
net_rshares | 3,899,102,781,864 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
xiguang | 0 | 1,564,912,417,630 | 100% | ||
crypto.income | 0 | 2,334,190,364,234 | 100% |