Tag: selenium

ElementNotVisible Exception

Selenium
Selenium ElementNotVisibleException is also one of the frequent exceptions which we will face in selenium webdriver while automating any kind of application. This exception tells you that the WebElement that you are trying to interact with is not visible to the user. If the element is not visible to the user then they are not going to able to interact with it   Below are the causes to face this exception: Thrown to indicate that although an element is present on the DOM, it is not visible, and so is not able to be interacted with. To overcome this kind of situation we need to use synchronization concept in selenium. So, add an explicit wait to wait for the correct conditions to be met before trying to interact with the element. We have an option to use wait in so many ways ...

NoSuchWindow Exception

Selenium
Selenium NoSuchWindowException is similar to NoSuchFrameException, this is also one of the frequent exceptions which we will face in selenium webdriver.   Sometimes applications will have child windows(i.e. Separate windows) which will open when you click on any link or button.   Normally if you want to automate the child windows then you need to switch to that window then only you can interact with the elements which are there on that window.   To overcome this, we need to handle the opened windows using one of the webdriver methods called “driver.getWindowHandles()”.   Once  you have this information then you can switch to the corresponding window to automate or interact with the window.     Below are the causes to face this ex
JavaScript Executor in Selenium

JavaScript Executor in Selenium

Level7, Selenium
As JavaScript Executor is an interface so we cannot create an object to this, for this we will type caste to driver object using below syntax:   JavascriptExecutor js = (JavascriptExecutor)driver; js.executeScript(javaScript, arguments); Now we will see some of the examples below that how we can use JavaScriptExecutor to execute the JavaScript to interact with the web elements.   1. How to enter value into textbox: JavascriptExecutor js = (JavascriptExecutor)driver; js.executeScript("document.getElementById('email').value='[email protected]'");   2. How to click a button: JavascriptExecutor js = (JavascriptExecutor)driver; js.executeScript("document.querySelector('#enterimg').click()");   3. How to refresh a window: JavascriptExecutor js = (Javascri...
Basic Selenium Commands

Basic Selenium Commands

Level1, Selenium
Get Command get() command is use to open a new web page in the current browser. Command: driver.get(“URL”); Example : driver.get("http://google.com");   Get Title Command getTitle() command is use to get the title of the current page. Example : driver.getTitle();   Get Current URL Command getCurrentUrl() command is use to get the URL of the page currently loaded in the browser. Example : driver.getCurrentUrl()   Close Command close() command is use to close the current window of the browser, if it’s the last window it will close the browser. Example : driver.close();   Quit Command quit() command is use to quit the browser and all the opened windows in the browser. Example : driver.quit();   Get Page Source Command