Friday, 6 January 2017

How to Open New Tab with Selenium WebDriver

Selenium WebDriver  tool do not have any built In API using which we can directly use to open new tab. Normally we are using CTRL + t Keys to open new tab In Browser and cltr + tab to switch between the tabs. We will use this in our selenium test case to open another tab inside a browser and switch to tab. 

Check out the Example below in details to understand how to open a new tab, how to open particular url in the new tab, how to switch between two tabs  and how to close the tabs.




import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class BromiumTests {

 WebDriver driver;
 Utils util;

 @BeforeTest
 public void setUp() {
  System.setProperty("webdriver.chrome.driver", "C:\\Softwares\\chromedriver_win32\\chromedriver.exe");
  driver = new ChromeDriver();
  driver.manage().window().maximize();
  driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  
 }

 
 
 @Test
 public void testOpenYoutube() {
  driver.get("https://www.youtube.com");
  
  driver.get("https://www.youtube.com/watch?v=9NXEnGiOeUU");
  driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

 }
        @Test
 public void testOpenGmail() {
  switchToNewTab();
  driver.get("http://www.gmail.com");
  driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
 }
       public void openNewTab() {
  ((JavascriptExecutor) driver).executeScript("window.open('about:blank','_blank');");
 }

 public void switchToNewTab() {
  openNewTab();
  String subWindowHandler = null;

  Set<String> handles = driver.getWindowHandles();
  Iterator<String> iterator = handles.iterator();
  while (iterator.hasNext()) {
   subWindowHandler = iterator.next();
  }
  driver.switchTo().window(subWindowHandler);
 }

 @AfterClass
 public void tearDown() {
  driver.quit();
 }
 

}

87 comments:

  1. Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.

    rpa Training in Bangalore

    ReplyDelete
  2. Nice Article, Please do post this kind of posts more, thanks.
    I wish you might like to have a look at my article http://javaseleniumworld.com/robot-class/

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. UiPath Training in Bangalore by myTectra is one the best UiPath Training. myTectra is the market leader in providing Robotic Process Automation on UiPath
    ui path training in bangalore

    ReplyDelete
  5. Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
    Sql&plsql Online Training

    workday Online Training

    SAP GTS Online Training

    Oracle BPM Online Training

    Oracle SCM Online Training

    ReplyDelete
  6. Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
    Splunk Classes

    Tableau Classes

    ReplyDelete
  7. This is good piece of writing and pleasant urging commented
    here, I am really enjoying by these.

    ReplyDelete
  8. Hey, very nice site. I came across this on Google, and I am stoked that I did. I will definitely be coming back here more often. Wish I could add to the conversation and bring a bit more to the table, but am just taking in as much info as I can at the moment. Thanks for sharing.

    Custom Web Application Development

    ReplyDelete
  9. Do not think! Just come with us to BGAOC and play with us. best casino games come to us and win soon.

    ReplyDelete
  10. buy soma pill 350mg
    Soma pill 350mg has carisoprodol that effectively treats acute pain in people. Pain is felt by almost everyone at some point of their life. This can at times make the life of the person very difficult. Soma pill 350mg has helped people all over the world. So use soma pill 350mg and get rid of all your body pain. Buy soma pill online and have a healthy pain free life.

    ReplyDelete
  11. BGAOC is the best online casino I've played. playing casino games Win as no one wins.

    ReplyDelete
  12. Супер отличная гибкая світлодіодна стрічка на любой вкус и цвет, обычно покупаю в интернет магазине.

    ReplyDelete
  13. No.1 Astrologer +91-9898765059 Best Jyotish Ahmedabad Astrologer Mahendra Joshi


    URL:


    http://astrologyindia.in

    Website :- www.astrologyindia.in

    ReplyDelete
  14. Thank you so much for the sharing it was useful and very informative. We're leading interior designers in chennai, we do all interior contract work.

    ReplyDelete
  15. One of the most trustworthy software to assist us call at immediate past may be the wondrous application of QuickBooks. QuickBooks Support Phone Number Running a business, it offers revolutionized our banking and changed the messy way we do finances. However, perhaps the best software often faces many errors during its functioning. Quite often, when utilizing QuickBooks, you would run into QuickBooks error code 15106 in your screen to get tantalized by it. However, nothing is to worry in this regard.

    ReplyDelete
  16. I love this post.

    โปรโมชั่นGclub ของทางทีมงานตอนนี้แจกฟรีโบนัส 50%
    เพียงแค่คุณสมัคร Gclub กับทางทีมงานของเราเพียงเท่านั้น
    ร่วมมาเป็นส่วนหนึ่งกับเว็บไซต์คาสิโนออนไลน์ของเราได้เลยค่ะ
    สมัครสมาชิกที่นี่ >>> Gclub online

    ReplyDelete
  17. Very cool!

    เว็บไซต์คาสิโนออนไลน์ที่ได้คุณภาพอับดับ 1 ของประเทศ
    เป็นเว็บไซต์การพนันออนไลน์ที่มีคนมา สมัคร Gclub Royal1688
    และยังมีเกมส์สล็อตออนไลน์ 1688 slot อีกมากมายให้คุณได้ลอง
    สมัครสมาชิกที่นี่ >>> Gclub Royal1688

    ReplyDelete
  18. QuickBooks Payroll Support Phone Number
    management quite definitely easier for accounting professionals. There are so many individuals who are giving positive feedback if they process payroll either QB desktop and online options

    ReplyDelete
  19. Nice Post thanks for the information, good information & very helpful for others. For more information about Why need Free Online Career Counselling & What Is Career Counselling? Career Counselling is a process that focuses on helping Click Here to Read More

    ReplyDelete
  20. IN QuickBooks Enterprise Support Phone Number All of them would be best inside their respective work area nevertheless when there clearly was a tiny glitch or error comes that might be a logical error or a technical glitch, can result producing or processing wrong information into the management or may wind up losing company’s precious data.

    ReplyDelete
  21. You might have trapped into a problem with Intuit product and payroll services? You're going to be ready to understand the best approach to get your hands on the Quickbooks Support Number. We welcome you 24*7 to access the various support services of Intuit products asking for help.

    ReplyDelete
  22. You will discover so many fields it covers like creating invoices, managing taxes, managing payroll etc. However exceptions are typical over, sometimes it makes the down sides and user wants QuickBooks Tech Support Number client Service help.

    ReplyDelete
  23. You will get some technical glitch. You will have errors also. Where do you realy turn? Take assistance from us straight away. We are going to provide full support to you. You are able to cope with the majority of the errors. We need to just coach you on something.
    VISIT : https://www.customersupportnumber247.com/

    ReplyDelete
  24. You could get resolve all of the major issues include installations problem, data access issue, printing related issue, software setup, server not responding error etc with our Quickbooks Support Phone Number.

    ReplyDelete
  25. The QB technicians are spontaneous and diligent to fix any QB issue , So business now save money as well time by calling the experts . One you connect with them the techies here to help you the best way they can. They are prompt and responsive in resolving the issue. Resolve any Quickbooks technical issue by the QuickBooks Suppport Phone Number.

    ReplyDelete
  26. Firstly, click on file and choose the chance Open & Restore. QuickBooks Support Phone Number Now open the file and click on Update Company File for New Version. And now maybe you are all set.

    ReplyDelete
  27. isn't an issue for all of us because problems try not to come with any pre-announcements. QuickBooks Support Phone Number There might be occasions once you might face some form of delay in reaching us,

    ReplyDelete
  28. The software has transformed and helped small & medium sized companies in many ways and managed their business successfully. The smart accounting software is richly featured with productive functionalities that save time and accuracy of the work. As it is accounting software, from time to time you may have a query and will seek assistance. This is the reason why QuickBooks has opened toll free Quickbooks Support. For telephone assistance just call or email to support team

    ReplyDelete
  29. The QuickBooks Payroll Tech Support Number has many awesome features that are good enough when it comes to small and middle sized business. QuickBooks Payroll also offers a dedicated accounting package which include specialized features for accountants also.

    ReplyDelete
  30. Sometimes it’s normal for users to have some performance-related issues in your QuickBooks due to your virus in your personal computer or some other computer related issues.In that case, you are annoying and you need some support to help you out. Here you can easily call us at our QuickBooks Payroll Support Phone Number to get instant help from our technical experts. However, if you would like speak to us quickly, you can easily reach us at QuickBooks Customer Support Number and all your queries may be solved instantly.

    ReplyDelete
  31. As QuickBooks Tech Support Phone Number Premier has various industry versions such as retail, manufacturing & wholesale, general contractor, general business, Non-profit & Professional Services, there is innumerous errors that will create your task quite troublesome.

    ReplyDelete
  32. Fix all of the issues for QuickBooks Payroll Support phone Number Desktop Payroll Basic, Standard, & Payroll Assisted. Check out the aforementioned number to get hold of our ProAdvisor to possess support for QuickBooks online Payroll support, Intuit Online & Full Service Payroll.

    ReplyDelete
  33. About having the most desirable and efficacious help on every issue you may possibly encounter yourself with. You merely need certainly to avail the assistance through the technical experts by dialing the QuickBooks Support Number.

    ReplyDelete
  34. The QuickBooks Payroll Support team at site name is held accountable for removing the errors that pop up in this desirable software. We care for not letting any issue can be purchased in in the middle of your work and trouble you in undergoing your tasks.

    ReplyDelete
  35. QuickBooks has almost changed it is of accounting. Nowadays accounting has exploded to become everyone’s cup of tea and that’s only become possible because because of the birth of QuickBooks accounting software. We have the best and the most convenient answer to enhance your productivity by solving every issue you face with the software. Give us a call at Support For QuickBooks to avail the greatest customer service services designed for you.

    ReplyDelete
  36. Call us any moment to get best answers to all or any the QuickBooks Payroll Error Support issues that you may come across with. QuickBooks payroll is quite promising, advanced and end to get rid of business accounting software.

    ReplyDelete
  37. Contact QuickBooks Support for prompt solutions. The QuickBooks Error Code 3371 is adept at providing pragmatic solutions that are probably the most strongly related your concerns.

    ReplyDelete
  38. Accurate Payroll Calculations the program will do all the math and keep close track of the tax rates and helps you calculate the QuickBooks Payroll support Phone with ease. The calculations are infallible as well as on time.

    ReplyDelete
  39. The guide might have helped you understand QuickBooks file corruption and methods to resolve it accordingly. If you would like gain more knowledge on file corruption or any other accounting issues, then we welcome you at our professional support center. It is simple to reach our staff via QuickBooks Payroll Tech Support & get required suggestion after all time. The group sitting aside understands its responsibility as genuine & offers reasonable assistance with your demand.

    ReplyDelete
  40. QuickBooks Enterprise Support Telephone Number Is Here to assist ease Your Accounting Struggle QuickBooks Support provides end-to end business accounting experience

    ReplyDelete
  41. You'll be able to very easily keep an eye on 50 employees at the same time and you also can monitor the sheer number of working hours of each employee. It helps you in calculating the complete soon add up to be paid to a worker depending through to the QuickBooks Payroll Support Number of hours he/she has contributed in their work.

    ReplyDelete
  42. The most unique feature of our team QuickBooks Payroll Support Phone Number is that it really is available for you 24*7. It works hard towards providing you with the greatest customer support and concentrate on achieving maximum customer care.

    ReplyDelete
  43. We offers you QuickBooks Enterprise Support Phone Number Team. Our technicians be sure you the security associated with the vital business documents. We have a propensity never to compromise utilizing the safety of one's customers.

    ReplyDelete
  44. Options now contain versions for manufacturers, wholesalers, professional firms, contractors and non-profit entities. And retailers, in adding to one precisely designed for professional accounting firms who service numerous small enterprise clients. In May 2002 Intuit thrown QuickBooks Enterprise Solutions for medium-sized businesses. QuickBooks Enterprise Help Number here to produce tech support team to users.

    ReplyDelete
  45. We At QuickBooks Enterprise Tech Support Phone Number Support, Listen To You Carefully And After Acquiring The Perfect Solution For The Solutions. We Start Solving Your Trouble Instantly.

    ReplyDelete
  46. Confused with your QuickBooks software or stuck in between making invoice ?You can reach us at QuickBooks Support to reach us for instant help. You simply have to dial Our QuickBooks Support phone number to attain our experts.

    ReplyDelete
  47. With our QuickBooks Tech Support Phone Number and ceaseless assistance, you too can have exactly the same flawless experience that millions of other QuickBooks users are enjoying at present. Relate solely to us to do the amazing functions with this Accounting Software

    ReplyDelete
  48. Quickbook Enterprise Support Number Helps A User To Get Assistance In Real Time. Although QuickBooks Enterprise Support Number Can Be Availed Using E-Mail And Online Chat Yet QuickBooks Enterprise Support Number Comes Out To Be Best Form Of Assistance.

    ReplyDelete
  49. Will you be sick and tired with the nagging QuickBooks Enterprise issues and searching for a few technical assistance in QuickBooks Enterprise Tech Support Number? It’s time and energy to say good bye to any or all your worries and present us a call today.

    ReplyDelete
  50. Thanks for this post, I really appriciate. I have read posts,
    all are in working condition. and I really like your writing style.
    autocad in bhopal
    3ds max classes in bhopal
    CPCT Coaching in Bhopal
    java coaching in bhopal
    Autocad classes in bhopal
    Catia coaching in bhopal

    ReplyDelete
  51. The Support Features Given By The QuickBooks Enterprise Support Are Advantageous To Those Who Regularly Utilize The Software. It Is Sold With User-Friendly Assistance Methods By Which An Individual Can Resolve His Issues Instantly. The QuickBooks Enterprise Support Phone Number System QuickBooks Enterprise Support Is Dedicated To Supply Step-By-Step Methods To The Issues Encountered By Existing And New Users.

    ReplyDelete
  52. Team also handle just about QuickBooks Enterprise Support Phone Number any technical & functional issue faced during installation that could have deleted system files, or damaged registry entries. Moreover, our QuickBooks Enterprise Customer Support.

    ReplyDelete
  53. Our team stands apart when considering to having experience. QuickBooks POS Tech Support Phone Number Its experience helps it in figuring out the exactly impacted regions of any error, reason behind error etc.

    ReplyDelete
  54. To have more enhanced results and optimized benefits, you are able to take the help of experts making a call at QuickBooks Payroll Support Number

    ReplyDelete
  55. This HP Printer contact number gives solid tech backings to any or all the HP clients. You will get the best answers for the issues from our master specialists. HP Printer Tech Support Team Number gives 24*7 administrations to your clients.

    ReplyDelete
  56. QuickBooks Error 6000, -301 occurs when accessing the company file in Quickbooks accounting software. This error could be brought on by various defect and damages to QuickBooks desktop. QuickBooks Error Code 6000-301 encounters while wanting to use a desktop company file.

    ReplyDelete
  57. This comment has been removed by the author.

    ReplyDelete
  58. No matter whether you are getting performance errors or perhaps you are facing any kind of trouble to upgrade your software to its latest version, you are able to quickly get advice about QuickBooks Support Phone Number. Each time you dial QuickBooks 2018 support phone number, your queries get instantly solved. Moreover, you could get in contact with our professional technicians via our email and chat support options for prompt resolution on most related issues.

    ReplyDelete
  59. You might be always able to relate with us at our QuickBooks Support contact number to extract the very best support services from our highly dedicated and supportive QuickBooks Support executives at any point of time as all of us is oftentimes prepared to work with you. Most of us is responsible and makes sure to deliver hundred percent assistance by working 24*7 to suit your needs. Go ahead and mail us at our QuickBooks Service Phone Number whenever you are in need. You could reach us via call at our toll-free number.

    ReplyDelete
  60. “Just dial our QuickBooks Payroll Support Number to inquire of about for Quickbooks Payroll customer service to get rid of payroll issues. We make use of startups to small-scale, medium-sized to multinational companies.”

    ReplyDelete
  61. Being an everyday person, you could think of various adventures and exciting things you can do, however if you run a company then all this work energy needs to be concentrated on various QuickBooks POS Tech Support Number

    ReplyDelete
  62. In conclusion, don’t hesitate to call us on our QuickBooks Online Help Number. We have been surely here for you personally. To conclude, any error, any difficulty, any bug or anything else associated with QuickBooks related problem, just call our QuickBooks Tech Support Number. Surely, call our Intuit QuickBooks Support

    ReplyDelete
  63. At QuickBooks Payroll Support Number, the buyer care team can help you in resolving every error that hinders the performance and speed with this work. All of us studies every issue beforehand and offers you the optimised solution. If you come with any issue which most of us is just not alert to then it`s not most likely a challenge when it comes to team since it's quick and sharp in finding out from the issue and resolving it straight away. Go right ahead and contact us anytime at Quickbooks Payroll customer care Support phone number.

    ReplyDelete
  64. QuickBooks has made payroll management quite definitely easier for accounting professionals. There are so many individuals who are giving positive feedback if they process payroll either QB desktop and online options. In this internet site, we are going to enable you to experience to make and place up the checklist for employee payment. To have more enhanced results and optimized benefits, you are able to take the help of experts making a call at QuickBooks Payroll Tech Support Number. Well! If you’re not in a position to customize employee payroll in Quickbooks while making the list optimally, in QB and QB desktop, then browse the description ahead. Here, you receive the determination of numerous kind of information what you’ve close by for assisting the setup process with comfort.

    ReplyDelete
  65. QuickBooks Payroll has emerged the best accounting software that has had changed the meaning of payroll. QuickBooks Payroll Service Phone Number could be the team that provide you Quickbooks Payroll Support. This software of QuickBooks comes with various versions and sub versions. Online Payroll and Payroll for Desktop may be the two major versions and they are further bifurcated into sub versions. Enhanced Payroll and Full-service payroll are encompassed in Online Payroll whereas Basic, Enhanced and Assisted Payroll come under Payroll for Desktop.

    ReplyDelete
  66. Welcome To Online Shopping Lucky Winner, ELIGIBILITY FOR PARTICIPATION, If you are an individual legal resident India and are 18 or older at the time of entry, you are eligible to enter the Sweepstakes. Our employees, their immediate family members (spouses, domestic partners, parents, grandparents, siblings, children and grandchildren), and our affiliates, advisors or advertising/promotion agencies (and their immediate family members) are not eligible to enter the Sweepstakes.

    ReplyDelete
  67. Is composed of a beautiful bunch of accounting versions, viz., QuickBooks Pro, QuickBooks Premier, QuickBooks Enterprise, QuickBooks POS, QuickBooks Mac, QuickBooks Windows, and QuickBooks Payroll, QuickBooks is now a dependable accounting software that you could tailor depending on your industry prerequisite. Along with it, our QuickBooks Phone Number will bring in dedicated and diligent back-end helps for you personally for in case you find any inconveniences in operating any of these versions.

    ReplyDelete
  68. Nice blog and great kind of information is provided by you. We provide quickbooks support phone number +1-800-901-6679 for the Quickbooks user help.

    ReplyDelete
  69. QuickBooks Tech Support Phone Number offers a multi-users feature that makes it possible for many users to operate the exact same computer to allow faster workflow. It enables businesses to help keep a track on employee information and ensures necessary consent because of the workers.

    ReplyDelete
  70. How come us different is quality of one's services inside the given time interval. The locus of your services will be based upon delivering services in shortest span of the time, without compromising aided by the quality of your services. QuickBooks Tech Support Number team is engaged in pre-research to produce themselves prepared in advance for the possible errors of QuickBooks. This practice helps them produce you the specified wind up in the given time window. We are there to help you 24*7 even as we do not disassociate ourselves with your troubles even through the wee hours.

    ReplyDelete
  71. But, being a typical business person, focusing on professional accounting software, like QuickBooks Tech Support Phone Number, is not always easy. Thus, users may need to face an amount of issues and error messages when using the software.

    ReplyDelete
  72. Brother Printer Support Number +1-888-600-5222.is high Quality device best Features available
    for Printer Help Anytime Printers can show error any time while setting it up or during a printing task. These technical glitches are unpredictable and it affects your work entirely,Brother Printer Support Phone Number. In the world of printers, Brother is one of the most well-known brands. Along with printers, Brother also manufactures lots of electrical types of equipment such as a desktop computer, fax machine, typewriters, etc.brother Printer Technical Support Number
    brother helpline Number
    brother Printer Support Number

    brother Printer Customer Support Number




    ReplyDelete
  73. So get quick help by contacting the QuickBooks Tech Support Number our toll-free number There are various kinds of bugs, glitches, and conditions that users can face while operating the QuickBooks.

    ReplyDelete