1. What is Selenium Testing?
Selenium is a cross-browser automation testing tool where a software tester writes a script in any of the supported languages like java, c#, ruby, python, etc to test the UI and UX in different browsers. There are three types of selenium tools available. Selenium Webdriver is used on the same OS, Selenium Grid for the different operating systems, and selenium IDE used as a chrome extension.
2.List few advantages of writing Selenium test cases
1. Automates cross-browser UI testing to test the experience of the same code on different browsers.
2. Performance testing through waits.
3. Control the browser at the operating system level in Webdriver
4. Ability to take screenshots and compare the output on different browsers.
5. Proxy with selenium helps in testing at different timezones, and under different content restrictions too.
3. Which languages does Selenium Webdriver Supports?
4.Where you cannot use Selenium testing?
Selenium is used to automate few test case scenarios but there are some test cases that must not be automated like captchas, two-factor authentication, file downloads, login in via Gmail, Facebook, etc as selenium is not designed to automate these test cases at all so one must avoid selenium testing there.
5. What is the latest version of Selenium Webdriver?
The latest Selenium version is 4.0 and before that selenium 3.0 and 2.0 were used. Selenium 4.0 adopted standard W3C protocol for webdriver for all the browser supports like chrome, safari, explorer. Hence the way the driver would interact with the browser would be based on W3 protocol only.
6. Why Selenium Webdriver replaced Selenium Remote Control?
Selenium Remote Control was a complex three-layer architecture where the communication was via a proxy server in RC. Hence Selenium RC acting as a middleware between the two clients and server whereas with the introduction of selenium webdriver, the process became much simpler as now could control the browser via a browser-specific driver which works basically at the operating system. Hence much simpler architecture
7. List a few Selenium locators.
4.driver.findElement(By.linkText("Click on the link"))
8. How to use the XPath locator?
When we have dynamic operators in the code, then using id, the name is worthless. Then XPath locator comes into the picture. Syntax of XPath:
9. What is the difference between Selenium Webdriver, IDE, and Grid
Selenium webdriver is used on the same machine where the browser, code, and driver are all located on the same operating system. But yes, in the case of the selenium remote web driver, the browser could be even located on a different operating system. IDE is mere a chrome extension and only available with chrome and firefox. Lastly, the grid has made it possible to test across two different systems via the concept of hub and node.
10. What is the difference between Implicit and Explicit Waits?
The implicit wait is across the driver and applied throughout the elements whereas explicit waits are subjected to elements where it is applied. Explicit wait provides maximum time for the operation to be performed before raising an exception. It is best used for handling the asynchronous nature of the browser and measuring the performance of the code as well. Explicit wait also have a feature of ExpectedConditions to give a broader scope as if an alertIsPresent etc.
Example: var wait = new WebDriverWait(driver, new TimeSpan(0, 0, 10));
11. Which wait is preferred and why?
The explicit wait is preferred as implicit just slows down the entire system. Also one should never mix both to avoid unpredictable results. And implicit could be applied to the element with obvious asynchronous nature and hence, one could measure the performance as well.
12. How do you use the selenium screenshot feature?
It is one of the best things in selenium is to be able to capture screenshots through scripts. As the major purpose of selenium is to test the result on a cross-browser platform. And screenshots are best for UI references. The below code is used in c# to capture screenshots which will save the element in the project folder. A screenshot could also be applied at the driver level.
Screenshot screenshot = (element as ITakesScreenshot).GetScreenshot();
13. Difference between Remote Webdriver and Webdriver.
Remote webdriver is best in the case of testing the application through a browser situated at a different system. This is done via hub and node where the node tells the hub(server) which configuration of driver and browser is required. And the hub has a browser to test the application. Selenium Webdriver is restricted to be on the same system only.
14.Advantage of using a proxy server with selenium
Proxy server masks the original IP address of the system. This offers a huge range of possibilities as one could use the IP of different countries to test time zones, location searches, and also there are content restriction policies in different countries. It opens up the endless possibility altogether in-browser application testing.
15. What is the difference between a proxy and a VPN
VPNs are more secured than proxy servers. Though both masks the original IP address of the system, VPN encrypts the data. VPN encrypts the entire data coming from other applications and traffic. Hence, even in public wifis always VPN must be used so that no one is getting the sensitive information of your system.
16. How do you handle alerts in selenium?
Selenium does provide the feature to handle alerts, confirmations, and popups. Though alerts have limited scope to play around with as one could only click OK here. But with confirmation, you can either Accept() or Deny(). Ultimately in popups, one could even enter value through keyboards and form inputs.
WebDriverWait wait = new WebDriverWait(driver, timeout: TimeSpan.FromSeconds(30));
IAlert alert = wait.Until(ExpectedConditions.AlertIsPresent());
17. How do you handle keyboard inputs in selenium?
selenium indeed provides few features to handle keyboard inputs through code to automate every manual intervention possible. And they are below:
1.sendKeys("abcd") provides input
2.keyDown(); // For control, Shift and ALT keys holding
3.keyUp();// For Control, Shift and ALT keys release
4.clear(); //clears the content of the textbox
18. Explain assets in selenium.
Assertions in selenium are used to verify that if the code is working according to the expectations or not. It returns a boolean.Assert.AssertFalse(condition) as true when the result is false similarly for other methods which are as:
19. What are desired capabilities in selenium?
desired capabilities and options both are used in selenium webdriver to tell the code to as what configuration of browser is being used here. BrowserName, location, platformName are some of the features of the element here in use.
20. List few drawbacks of selenium testing.
1. Limited usage for UI and UX only.
2. Not much to play around with in terms of performance and loads
3.Since it is an open-source tool, even the tech support is pretty limited and releases are too slow comparatively.