Using Robot We can Handle Multiple Tabs in Selenium
package samples;
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.Test;
/**
*
* @author krishnareddy
*
*/
public class MultiTabs {
@Test
public void multiTabs() throws AWTException {
// System.setProperty("webdriver.chrome.driver",
// "Drivers\\chromedriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("http://www.gtpvkr.in/2014/08/handling-authentication-dialog-box.html");
;
// driver.findElement(By.xpath(""));
//open new tab
new Actions(driver)
.contextClick(
driver.findElement(By
.xpath("//*[@id='rsidebar-wrapper']/div[1]/div/a[4]/img")))
.sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ENTER).build()
.perform();
// System.out.println(driver.getWindowHandles().size());
Robot robot = new Robot();
/*
* robot.keyPress(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_TAB);
*
* robot.keyRelease(KeyEvent.VK_CONTROL);
* robot.keyRelease(KeyEvent.VK_TAB);
*/
//close current tab
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_W);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_W);
//get current tab title
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
System.out.println(driver.getTitle());
//click on any element
driver.findElement(By.xpath("//*[@id='nav-legal']/li[1]/a")).click();
//get back previous tab
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_SHIFT);
robot.keyPress(KeyEvent.VK_T);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_SHIFT);
robot.keyRelease(KeyEvent.VK_T);
}
}
package samples;
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.Test;
/**
*
* @author krishnareddy
*
*/
public class MultiTabs {
@Test
public void multiTabs() throws AWTException {
// System.setProperty("webdriver.chrome.driver",
// "Drivers\\chromedriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("http://www.gtpvkr.in/2014/08/handling-authentication-dialog-box.html");
;
// driver.findElement(By.xpath(""));
//open new tab
new Actions(driver)
.contextClick(
driver.findElement(By
.xpath("//*[@id='rsidebar-wrapper']/div[1]/div/a[4]/img")))
.sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ENTER).build()
.perform();
// System.out.println(driver.getWindowHandles().size());
Robot robot = new Robot();
/*
* robot.keyPress(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_TAB);
*
* robot.keyRelease(KeyEvent.VK_CONTROL);
* robot.keyRelease(KeyEvent.VK_TAB);
*/
//close current tab
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_W);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_W);
//get current tab title
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
System.out.println(driver.getTitle());
//click on any element
driver.findElement(By.xpath("//*[@id='nav-legal']/li[1]/a")).click();
//get back previous tab
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_SHIFT);
robot.keyPress(KeyEvent.VK_T);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_SHIFT);
robot.keyRelease(KeyEvent.VK_T);
}
}
Thanks for Sharing this blog it is very helpful to us ...... Selenium Online Training
ReplyDelete
ReplyDeleteThank you for this great article which is about multi tabs handling using selenium .keep more updates.
SEO Company in India
Very Nice...Contains A to Z concepts...Thanks a lot.. and looking for the best selenium training in Chennai with certification from us. we have experienced selenium experts offer selenium course training with industry exposure. Check Here https://goo.gl/VRNEXv
ReplyDeleteThe Blog gave idea to set up multitabs using selenium The Code Shared are very much useful My sincere thanks for sharing this post Please Keep on sharing this type of post
ReplyDeleteSelenium Training in Bangalore
Thanks for sharing this article. Really useful for me to understand about selenium multi tabs handling. software testing training in Bangalore
ReplyDeleteReally very nice informative article about the multi tabs handling... Keep in blogging regularly to update these kinds of useful informative...
ReplyDeleteSelenium Training in Velachery|Best Selenium Training in Velachery|Selenium Training in Chennai
It’s a shame you don’t have a donate button! I’d certainly donate to this brilliant blog! I suppose for now I’ll settle for book-marking and adding your RSS feed to my Google account. I look forward to fresh updates and will talk about this blog with my Facebook group. Chat soon!
ReplyDelete<a href="http://www.traininginmarathahalli.in/selenium-training-in-bangalore/”> Selenium Training in Marathahalli </a>|
awesome post presented by you..your writing style is fabulous and keep update with your blogs.
ReplyDeleteselenium Online Training Bangalore
Excellent Article ...thank u for sharing, such a valuable content Learners to get good knowledge after read this article.. Selenium Training in Chennai | Selenium Training in Chennai
ReplyDeleteThis is one awesome blog article. Much thanks again. selenium Online course Hyderabad
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteSelenium training
ReplyDeleteSelenium training in Chennai
Selenium training institutes in Chennai
selenium testing training in Chennai
With practical you described selenium with java, it will be very helpful. Thank you so much.
ReplyDeleteSelenium Testing Training in Pune
At Coepd - (Center of Excellence for Professional Development) Manual & Selenium testing training program is designed to give participants the skills & knowledge to gain a competitive advantage in starting/enhancing a career in software testing. We provide the attendee's software testing service which is required to ensure that tested applications meet all application requirements. Participants receive up-to-date training in multiple areas in Software Testing and a thorough understanding of real-world projects. Our collaborative ecosystem comprising of Partnerships with Software Companies enables real time software test life cycle experience.
ReplyDeletehttp://www.coepd.com/TestingTraining.html
I like your post and appreciate your effort in this code. Keep sharing also in future. It will be really helpful for us. Thanks a lot.
ReplyDeleteselenium training in pune
selenium training institute in pune
I‘d mention that most of us visitors are endowed to exist in a fabulous place with very many wonderful individuals with very helpful things... RPA Training in Chennai | Blue Prism Training in Chennai
ReplyDeleteThanks for sharing the more valuable information to share with us. For more information please visit our website. Testing Tools Training in Hyderabad
ReplyDeleteThank you for sharing such a valuble information
ReplyDeletesap simple finance online training institute in hyderabad
Very nice information, keep share more post..
ReplyDeleteBest Selenium Training Institute in Bangalore | Best Selenium Training in Bangalore | Selenium Training Institutes in Bangalore | Software Testing Training in Bangalore
Thanks for sharing this valuable information to our vision
ReplyDeleteRPA Online Training in Hyderabad
Thanks for the good words! Really appreciated. Great post. I’ve been commenting a lot on a few blogs recently, but I hadn’t thought about my approach until you brought it up.
ReplyDeleteJava training in Chennai | Java training in Annanagar | Java training in Chennai
Java training in Chennai | Java training in Bangalore | Java training in Electronic city
This blog is the general information for the feature. You got a good work for these blog.We have a developing our creative content of this mind.Thank you for this blog. This for very interesting and useful.
ReplyDeletepython course in pune | python course in chennai | python course in Bangalore
You blog post is just completely quality and informative. Many new facts and information which I have not heard about before. Keep sharing more blog posts.
ReplyDeleteData Science training in Chennai | Data Science Training Institute in Chennai | Data science training in Bangalore | Data Science Training institute in Bangalore
Data science training in pune | Data Science training institute in Pune | Data science online training | online Data Science certification Training-Gangboard
Data Science Interview questions and answers
Awesome article. It is so detailed and well formatted that i enjoyed reading it as well as get some new information too.
ReplyDeleteJava training in Chennai | Java training in Bangalore
Java online training | Java training in Pune
Pleasant Tips..Thanks for Sharing….We keep up hands on approach at work and in the workplace, keeping our business pragmatic, which recommends we can help you with your tree clearing and pruning in an invaluable and fit way.
ReplyDeleteData Science training in kalyan nagar | Data Science training in OMR | Data science training in chennai
Data Science training in chennai | Best Data science Training in Chennai | Data science training in velachery | Data Science Training in Chennai
Data science training in tambaram | Data Science training in Chennai | Data science training in jaya nagar | Data science Training in Bangalore
After seeing your article I want to say that the presentation is very good and also a well-written article with some very good information which is very useful for the readers....thanks for sharing it and do share more posts like this.
ReplyDeletepython course institute in bangalore
python Course institute in bangalore
python course institute in bangalore
Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information.
ReplyDeleteangularjs interview questions and answers
angularjs Training in bangalore
angularjs Training in bangalore
angularjs Training in chennai
automation anywhere online Training
ReplyDeleteWhoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.
Best Selenium Interview Questions and Answers | No.1 Selenium Interview Questions and Answers
Advanced Selenium Training in Chennai | Selenium Training Institute in Chennai | selenium interview Questions and Answers
No.1 Selenium Training in Bangalore | Best Selenium Training Institute in Bangalore
Free Selenium Tutorial Training |Advanced Selenium Web driver Tutorial For Beginners
In the beginning, I would like to thank you much about this great post. Its very useful and helpful for anyone looking for tips to help him learn and master in Angularjs. I like your writing style and I hope you will keep doing this good working.
ReplyDeleteAngularjs Training in Bangalore
Angularjs Training Institute In Bangalore
Angularjs Course in Bangalore
Android Institute in Bangalore
Android Coaching in Bangalore
Android Coaching Center in Bangalore
Well with your permission let me grab your RSS feed to keep updated with forthcoming post. Thanks a million, and please keep up the gratifying work.
ReplyDeleteindustrial course in chennai
Awesome post. Really you are shared very informative concept... Thank you for sharing. Keep on
ReplyDeleteupdating…
Education
Technology
Really great information!!! Thanks for your blog.
ReplyDeleteGerman Language Training in Coimbatore
German Classes Near Me
German Language Classes Near Me
Best German Language Course
German Language Training
Thanks for your interesting ideas.the information's in this blog is very much useful
ReplyDeletefor me to improve my knowledge.
Angular JS Training courses near me
AngularJS Training in Anna Nagar
best angularjs training in Bangalore
Angularjs Training Bangalore
Informative post, thanks for taking time to share this page.
ReplyDeleteccna course in Chennai
Python Training in Chennai
R Programming Training in Chennai
Data Science Course in Chennai
Very informative post
ReplyDeleteaws training in hyderabad
I really enjoy simply reading all of your weblogs.
ReplyDeleteSelenium Training Institute in Pune
I just love smart home automation, it makes things so much fun and easier for us. My sister has just install a project like this in their home and they are very satisfied. Thanks for your prolonged articles I will also get one. Keep sharing the good stuff.
ReplyDeleteHi there! I simply want to offer you a huge thumbs up for your great information you have here on this post. I am coming back to your blogfor more soon.
ReplyDeleteGreat information. Lucky me I came across your website by chance. I've book-marked it for later!
ReplyDeleteUI Development Training in Bangalore
Reactjs Training in Bangalore
Such an excellent and interesting blog, do post like this more with more information, this was very useful. Salesforce Training India
ReplyDeleteWonderful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article resolved my all queries.
ReplyDeleteData Science
Python
Selenium
ETL Testing
AWS
This comment has been removed by the author.
ReplyDeleteThis blog, in my opinion, is among the best because it has been quite beneficial to me. I appreciate you sharing this useful information.
ReplyDeleteIELTS Coaching in Vadodara