

XML AJAX AJAX Introduction AJAX XMLHttp AJAX Request AJAX Response AJAX XML File AJAX PHP AJAX ASP AJAX Database AJAX Applications AJAX Examples Wait.until(ExpectedConditions.elementToBeClickable(By.XML Tutorial XML HOME XML Introduction XML How to use XML Tree XML Syntax XML Elements XML Attributes XML Namespaces XML Display XML HttpRequest XML Parser XML DOM XML XPath XML XSLT XML XQuery XML XLink XML Validator XML DTD XML Schema XML Server XML Examples XML Quiz XML Certificate WebDriverWait wait = new WebDriverWait(driver, 30) In 5 to 10% cases, This step will resolve your Issue.

If It Is taking more than 15 seconds then you have to put explicit wait condition with 20 or more seconds wait period as bellow. If Implicit wait Is already added and element locator Is fine then you need to verify that how much time It(element) Is taking to appear on page. In 70% cases, this step will resolved Issue.ĭriver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS) So I will add bellow given line at beginning of my test case code to wait for 15 seconds for element to be present on page. If you have not placed Implicit timeout In your test and any element Is taking some time to appear on page then you can get this exception. To resolved this Issue, I will check bellow given things.įirst of all I will check that I have placed Implicit wait code In my test or not. You will get this exception when WebDriver Is not able to locate element on the page of software web application using whatever locator you have used In your test. So having this class implemented you can use import static SingletonWebDriver to your test classes and use getDriver() instead of driver in your code.

If you need to force everyone to use the only single driver in all the tests and all the users of your framework, then you can implement Singleton pattern like shown below:ĭriver = new ChromeDriver() // Here you can introduce some logic on what particular driver to instantiate. If you still need to use the same instance you may set your WebDriver as a static field of some class, initialize it once, and then just take that field when you need WebDriver in all your tests. If you use the same driver for all your tests you should carefully use quit() and close() methods. Since all the changed you will introduce to WebDriver object in one test will have the place in another tests which might impact the logic. I would not recommend to use the same WebDriver instance in different tests because that would make your tests dependent on each other. To call non-static methods you need to instantiate objects first. You cannot use this line WebDriver driver = InitializeDriver.getDriver() because your getDriver() method is not static (according to your example).
