{"id":28042,"date":"2022-03-02T09:10:42","date_gmt":"2022-03-02T09:10:42","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=28042"},"modified":"2025-08-28T23:47:12","modified_gmt":"2025-08-28T23:47:12","slug":"top-50-selenium-interview-questions-and-answers","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/top-50-selenium-interview-questions-and-answers\/","title":{"rendered":"Top 50 selenium interview questions and answers"},"content":{"rendered":"\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"384\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/03\/banner-selenium-1024x384.png\" alt=\"\" class=\"wp-image-28043\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/03\/banner-selenium-1024x384.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/03\/banner-selenium-300x113.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/03\/banner-selenium-768x288.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/03\/banner-selenium-1536x576.png 1536w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/03\/banner-selenium.png 2000w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption><em><strong>Selenium interview questions and answers<\/strong><\/em> <\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">1) What is Selenium and what is composed of?<\/h2>\n\n\n\n<p>Selenium is a suite of tools for automated web testing. It is composed of<\/p>\n\n\n\n<p>Selenium IDE (Integrated Development Environment) : It is a tool for recording and playing back. It is a firefox plugin<br>WebDriver and RC: It provide the APIs for a variety of languages like Java, .NET, PHP, etc. With most of the browsers Webdriver and RC works.<br>Grid: With the help of Grid you can distribute tests on multiple machines so that test can be run parallel which helps in cutting down the time required for running in browser test suites.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2) How will you find an element using Selenium?<\/h2>\n\n\n\n<p>In Selenium every object or control in a web page is referred as an elements, there are different ways to find an element in a web page they are<\/p>\n\n\n\n<p>ID<br>Name<br>Tag<br>Attribute<br>CSS<br>Linktext<br>PartialLink Text<br>Xpath etc<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3) List out the test types that are supported by Selenium?<\/h2>\n\n\n\n<p>For web based application testing selenium can be used<\/p>\n\n\n\n<p>The test types can be supported are<\/p>\n\n\n\n<p>a) Functional, Learn More about Functional Testing.<\/p>\n\n\n\n<p>b) Regression<\/p>\n\n\n\n<p>For post release validation with continuous integration automation tool could be used<\/p>\n\n\n\n<p>a) Jenkins<\/p>\n\n\n\n<p>b) Hudson<\/p>\n\n\n\n<p>c) Quick Build<\/p>\n\n\n\n<p>d) CruiseCont<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4) List out the test types that are supported by Selenium?<\/h2>\n\n\n\n<p>For web based application testing selenium can be used<\/p>\n\n\n\n<p>The test types can be supported are<\/p>\n\n\n\n<p>a) Functional, Learn More about Functional Testing.<\/p>\n\n\n\n<p>b) Regression<\/p>\n\n\n\n<p>For post release validation with continuous integration automation tool could be used<\/p>\n\n\n\n<p>a) Jenkins<\/p>\n\n\n\n<p>b) Hudson<\/p>\n\n\n\n<p>c) Quick Build<\/p>\n\n\n\n<p>d) CruiseCont<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5) Explain what is assertion in Selenium and what are the types of assertion?<\/h2>\n\n\n\n<p>Assertion is used as a verification point. It verifies that the state of the application conforms to what is expected. The types of assertion are \u201cassert\u201d , \u201cverify\u201d and \u201cwaitFor\u201d.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">6) Mention what is the use of X-path?<\/h2>\n\n\n\n<p>X-Path is used to find the WebElement in web pages. It is also useful in identifying the dynamic elements.<\/p>\n\n\n\n<p>Refer Complete Guide on XPath<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">7) Explain the difference between single and double slash in X-path?<\/h2>\n\n\n\n<p>Single slash \u2018\/ \u2019<\/p>\n\n\n\n<p>Single slash ( \/ ) start selection from the document node<br>It allows you to create \u2018absolute\u2019 path expressions<br>Double Slash \u2018\/\/ \u2019<\/p>\n\n\n\n<p>Double slash ( \/\/ ) start selection matching anywhere in the document<br>It enables to create \u2018relative\u2019 path expressions<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">8) List out the technical challenges with Selenium?<\/h2>\n\n\n\n<p>Technical challenges with Selenium are<\/p>\n\n\n\n<p>Selenium supports only web based applications<br>It does not support the Bitmap comparison<br>For any reporting related capabilities have to depend on third party tools<br>No vendor support for tool compared to commercial tools like HP UFT<br>As there is no object repository concept in Selenium, maintainability of objects becomes difficult<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">9) What is the difference between type keys and type commands?<\/h2>\n\n\n\n<p>TypeKeys() will trigger JavaScript event in most of the cases whereas .type() won\u2019t. Type key populates the value attribute using JavaScript whereas .typekeys() emulates like actual user typing<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">10) What is the difference between verify and assert commands?<\/h2>\n\n\n\n<p>Assert: Assert allows to check whether an element is on the page or not. The test will stop on the step failed, if the asserted element is not available. In other words, the test will terminated at the point where check fails.<\/p>\n\n\n\n<p>Verify: Verify command will check whether the element is on the page, if it is not then the test will carry on executing. In verification, all the commands are going to run guaranteed even if any of test fails.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">11) What is JUnit Annotations and what are different types of annotations which are useful?<\/h2>\n\n\n\n<p>In JAVA a special form of syntactic meta-data can be added to Java source code, this is know as Annotations. Variables, parameters, packages, methods and classes are annotated some of the Junit annotations which can be useful are<\/p>\n\n\n\n<p>Test<br>Before<br>After<br>Ignore<br>BeforeClass<br>AfterClass<br>RunWith<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">12) While using click command can you use screen coordinate?<\/h2>\n\n\n\n<p>To click on specific part of element, you would need to use clickAT command. ClickAt command accepts element locator and x, y co-ordinates as arguments-<\/p>\n\n\n\n<p>clickAt (locator, cordString)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">13) What are the advantages of Selenium?<\/h2>\n\n\n\n<p>It supports C#, PHP, Java, Perl, Phython<br>It supports different OS like Windows, Linux and Mac OS<br>It has got powerful methods to locate elements (Xpath, DOM , CSS)<br>It has highly developer community supported by Google<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">14) Why testers should opt for Selenium and not QTP?<\/h2>\n\n\n\n<p>Selenium is more popular than QTP as<\/p>\n\n\n\n<p>Selenium is an open source whereas QTP is a commercial tool<br>Selenium is used specially for testing web based applications while QTP can be used for testing client server application also<br>Selenium supports Firefox, IE, Opera, Safari on operating systems like Windows, Mac, Linux etc. however QTP is limited to Internet Explorer on Windows.<br>Selenium supports many programming languages like Ruby, Perl, Python whereas QTP supports only VB script<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">15) What are the four parameter you have to pass in Selenium?<\/h2>\n\n\n\n<p>Four parameters that you have to pass in Selenium are<\/p>\n\n\n\n<p>Host<br>Port Number<br>Browser<br>URL<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">16) What is the difference between setSpeed() and sleep() methods?<\/h2>\n\n\n\n<p>Both will delay the speed of execution.<\/p>\n\n\n\n<p>Thread.sleep () : It will stop the current (java) thread for the specified period of time. Its done only once<\/p>\n\n\n\n<p>It takes a single argument in integer format<br>Ex: thread.sleep(2000)- It will wait for 2 seconds<\/p>\n\n\n\n<p>It waits only once at the command given at sleep<br>SetSpeed () : For specific amount of time it will stop the execution for every selenium command.<\/p>\n\n\n\n<p>It takes a single argument in integer format<br>Ex: selenium.setSpeed(\u201c2000\u201d)- It will wait for 2 seconds<\/p>\n\n\n\n<p>Runs each command after setSpeed delay by the number of milliseconds mentioned in set Speed<br>This command is useful for demonstration purpose or if you are using a slow web application<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">17) What is same origin policy? How you can avoid same origin policy?<\/h2>\n\n\n\n<p>The \u201cSame Origin Policy\u201d is introduced for security reason, and it ensures that content of your site will never be accessible by a script from another site. As per the policy, any code loaded within the browser can only operate within that website\u2019s domain.<\/p>\n\n\n\n<p>To avoid \u201cSame Origin Policy\u201d proxy injection method is used, in proxy injection mode the Selenium Server acts as a client configured HTTP proxy , which sits between the browser and application under test and then masks the AUT under a fictional URL<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">18) What is heightened privileges browsers?<\/h2>\n\n\n\n<p>The purpose of heightened privileges is similar to Proxy Injection, allows websites to do something that are not commonly permitted. The key difference is that the browsers are launced in a special mode called heightened privileges. By using these browser mode, Selenium core can open the AUT directly and also read\/write its content without passing the whole AUT through the Selenium RC server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">19) How you can use \u201csubmit\u201d a form using Selenium?<\/h2>\n\n\n\n<p>You can use \u201csubmit\u201d method on element to submit form-<\/p>\n\n\n\n<p>element.submit () ;<\/p>\n\n\n\n<p>Alternatively you can use click method on the element which does form submission<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">20) What are the features of TestNG and list some of the functionality in TestNG which makes it more effective?<\/h2>\n\n\n\n<p>TestNG is a testing framework based on JUnit and NUnit to simplify a broad range of testing needs, from Unit Testing to Integration Testing. And the functionality which makes it efficient testing framework are<\/p>\n\n\n\n<p>Support for annotations<br>Support for data-driven testing<br>Flexible test configuration<br>Ability to re-execute failed test cases<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">21) What are the advantages of automation testing?<\/h2>\n\n\n\n<p>Some basic Advantages of automation testing are as follows.<\/p>\n\n\n\n<p>Automation testing supports both functional and performance test on an application.<br>It supports the execution of repeated test cases.<br>It facilitates parallel execution.<br>It aids in testing a large test matrix.<br>It improves accuracy because there are no chances of human errors.<br>It saves time and money.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">22) Name some of the commonly used Automation Testing tools that are used for Functional Automation.<\/h2>\n\n\n\n<p>Lists of top 10 used automation testing tools for Functional Automation are as follows.<\/p>\n\n\n\n<p>Teleric Test Studio, Developed by Teleric.<br>TestingWhiz<br>HPE Unified Functional Testing (HP &#8211; UFT formerly QTP)<br>Tosca Testsuite<br>Watir<br>Quick Test Professional, provided by HP.<br>Rational Robot, provided by IBM.<br>Coded UI, provided by Microsoft.<br>Selenium, open source.<br>Auto It, Open Source.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">23) Name some of the commonly used Automation Testing tools that are used for Non-Functional Automation.<\/h2>\n\n\n\n<p>Lists of some commonly used Automation Testing tools for Non-Functional Automation are as follows.<\/p>\n\n\n\n<p>Load Runner, provided by Hp.<br>JMeter, provided by Apache.<br>Burp Suite, provided by PortSwigger.<br>Acunetix, provided by Acunetix.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">24) What is Selenium?<\/h2>\n\n\n\n<p>Selenium is a portable framework for software testing. Selenium tool facilitates with a playback tool for authoring functional tests without the need to learn a test scripting language.<\/p>\n\n\n\n<p>Selenium is one of the most widely used open source Web UI (User Interface) automation testing suite. Jason Huggins developed Selenium in 2004 as an internal tool at Thought Works. Selenium supports automation across different browsers, platforms, and programming languages.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">25) What are the different components of Selenium?<\/h2>\n\n\n\n<p>Selenium is not just a single tool but a suite of software&#8217;s, each having a different approach to support automation testing. It comprises of four major components which include:<\/p>\n\n\n\n<p>Selenium Integrated Development Environment (IDE)<br>Selenium Remote Control (Now Deprecated)<br>WebDriver<br>Selenium Grid<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">26) List out the names of programming languages, browsers and operating systems that are supported by Selenium.<\/h2>\n\n\n\n<p>Selenium supports various operating systems, browsers and programming languages. Following is the list:<\/p>\n\n\n\n<p>Programming Languages: C#, Java, Python, PHP, Ruby, Perl, JavaScript.<br>Operating Systems: Android, iOS, Windows, Linux, Mac, Solaris.<br>Browsers: Google Chrome, Mozilla Firefox, Internet Explorer, Edge, Opera, Safari, etc.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">27) What are the significant changes\/upgrades in various Selenium versions?<\/h2>\n\n\n\n<p>Selenium v1.0:<\/p>\n\n\n\n<p>Version 1.0 was the initial release of Selenium.<br>It included three tools: Selenium IDE, Selenium RC, and Selenium Grid.<br>Selenium v2.0:<\/p>\n\n\n\n<p>Selenium WebDriver was introduced replacing Selenium RC in version &#8220;2.0&#8221;.<br>With the onset of WebDriver, RC got deprecated and moved to the legacy package.<br>Selenium v3:<\/p>\n\n\n\n<p>The latest release Selenium 3 has new added features and functionalities.<br>It includes Selenium IDE, Selenium WebDriver, and Selenium Grid.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">28) List some of the test types that are supported by Selenium.<\/h2>\n\n\n\n<p>Different types of testing&#8217;s that we can achieve through Selenium are.<\/p>\n\n\n\n<p>Functional Testing<br>Regression Testing<br>Sanity Testing<br>Smoke Testing<br>Responsive Testing<br>Cross Browser Testing<br>UI testing (black box)<br>Integration Testing<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">29) What is Selenium IDE?<\/h2>\n\n\n\n<p>Selenium IDE is implemented as Firefox extension which provides record and playback functionality on test scripts. It allows testers to export recorded scripts in many languages like HTML, Java, Ruby, RSpec, Python, C#, JUnit and TestNG.<\/p>\n\n\n\n<p>Selenium IDE has limited scope, and the generated test scripts are not very robust, and portable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">30) What do you mean by Selenese?<\/h2>\n\n\n\n<p>Selenium commands, also known as &#8220;Selenese&#8221; are the set of commands used in Selenium that run your tests. For example, command &#8211; open (URL); launches the desired URL in the specified browser and it accept both relative and absolute URLs.<\/p>\n\n\n\n<p>A sequence of Selenium commands (Selenese) together is known as a test script.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">31) What are the different ways of locating a web element in Selenium?<\/h2>\n\n\n\n<p>In Selenium, web elements are identified and located with the help of Locators. Locators specify a target location which uniquely defines the web element in the context of a web application. Thus, to identify web elements accurately and precisely we have different types of locators in Selenium:<\/p>\n\n\n\n<p>ID<br>ClassName<br>Name<br>TagName<br>LinkText<br>PartialLinkText<br>Xpath<br>CSS Selector<br>DOM<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">32) How many types of WebDriver API&#8217;s are available in Selenium?<\/h2>\n\n\n\n<p>The list of WebDriver API&#8217;s which are used to automate browser include:<\/p>\n\n\n\n<p>AndroidDriver<br>ChromeDriver<br>EventFiringWebDriver<br>FirefoxDriver<br>HtmlUnitDriver<br>InternetExplorerDriver<br>iPhoneDriver<br>iPhoneSimulatorDriver<br>RemoteWebDriver<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">33) List out some of the Automation tools which could be integrated with Selenium to achieve continuous testing.<\/h2>\n\n\n\n<p>Selenium can be used to automate functional tests and can be integrated with automation test tools such as Maven, Jenkins, &amp;Docker to achieve continuous testing. It can also be integrated with tools such as TestNG, &amp;JUnit for managing test cases and generating reports.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">34) What do you mean by the assertion in Selenium?<\/h2>\n\n\n\n<p>The assertion is used as a verification point. It verifies that the state of the application conforms to what is expected. The types of assertion are &#8220;assert&#8221;, &#8220;verify&#8221; and &#8220;waitFor&#8221;.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">35) Explain the difference between assert and verify commands?<\/h2>\n\n\n\n<p>Assert: Assert command checks if the given condition is true or false. If the condition is true, the program control will execute the next phase of testing, and if the condition is false, execution will stop, and nothing will be executed.<\/p>\n\n\n\n<p>Verify: Verify command also checks if the given condition is true or false. It doesn&#8217;t halt program execution, i.e., any failure during verification would not stop the execution, and all the test phases would be executed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">36) What do you mean by XPath?<\/h2>\n\n\n\n<p>XPath is also defined as XML Path. It is a language used to query XML documents. It is an important approach to locate elements in Selenium. XPath consists of a path expression along with some conditions. Here, we can easily write XPath script\/query to locate any element in the webpage. It is developed to allow the navigation of XML documents. The key factors that it considered while navigating are selecting individual elements, attributes, or some other part of an XML document for specific processing. It also produces reliable locators. Some other points about XPath are as follows.<\/p>\n\n\n\n<p>XPath is a language used for locating nodes in XML documents.<br>XPath can be used as a substitute when you don&#8217;t have a suitable id or name attribute for the element you want to locate.<br>XPath provides locating strategies like:<br>XPath Absolute<br>XPath Attributes<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">37) Explain XPath Absolute and XPath attributes.<\/h2>\n\n\n\n<p>XPath Absolute:<\/p>\n\n\n\n<p>XPath Absolute enables users to mention the complete XPath location from the root HTML tag to the specific elements.<br>Syntax: \/\/html\/body\/tag1[index]\/tag2[index]\/\u2026\/tagN[index]<br>Example: \/\/html\/body\/div[2]\/div\/div[2]\/div\/div\/div\/fieldset\/form\/div[1]\/input[1]<br>XPath Attributes:<\/p>\n\n\n\n<p>XPath Attributes is always recommended when you don&#8217;t have a suitable id or name attribute for the element you want to locate.<br>Syntax: \/\/htmltag[@attribute1=&#8217;value1&#8242; and @attribute2=&#8217;value2&#8242;]<br>Example: \/\/input[@id=&#8217;passwd&#8217; and @placeholder=&#8217;password&#8217;]<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">38) What is the difference between &#8220;\/&#8221; and &#8220;\/\/&#8221; in XPath?<\/h2>\n\n\n\n<p>Single Slash &#8220;\/&#8221;: Single slash is used to create XPath with absolute path.<\/p>\n\n\n\n<p>Double Slash &#8220;\/\/&#8221;: Double slash is used to create XPath with the relative path.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">39) What are the different types of annotations which are used in Selenium?<\/h2>\n\n\n\n<p>JUnit annotations which can be used are:<\/p>\n\n\n\n<p>Test<br>Before<br>After<br>Ignore<br>BeforeClass<br>AfterClass<br>RunWith<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">40) What are the WebDriver supported Mobile Testing Drivers?<\/h2>\n\n\n\n<p>WebDriver supported &#8220;mobile testing drivers&#8221; are:<\/p>\n\n\n\n<p>AndroidDriver<br>IphoneDriver<br>OperaMobileDriver<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">41) Which browsers\/drivers are supported by Selenium Webdriver?<\/h2>\n\n\n\n<p>Some commonly used browsers supported by Selenium are-<\/p>\n\n\n\n<p>Google Chrome \u2013 ChromeDriver<br>Firefox \u2013 FireFoxDriver<br>Internet Explorer \u2013 InternetExplorerDriver<br>Safari \u2013 SafariDriver<br>HtmlUnit (Headless browser) \u2013 HtmlUnitDriver<br>Android \u2013 Selendroid\/Appium<br>IOS \u2013 ios-driver\/Appium<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">42) Can we test APIs or web services using Selenium Webdriver?<\/h2>\n\n\n\n<p>No. Selenium WebDriver uses the browser\u2019s native method to automate the web applications. So, there is no support for testing web services using Selenium WebDriver.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">43) What are the various ways of locating an element in Selenium?<\/h2>\n\n\n\n<p>The different locators in Selenium are-<\/p>\n\n\n\n<p>Id<br>XPath<br>CSS selector<br>className<br>tagName<br>name<br>link text<br>partialLinkText<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">44) How can we inspect the web element attributes in order to use them in different locators?<\/h2>\n\n\n\n<p>In order to locate web elements, we can use the Developer tool and plugins like Firebug.<br>The developer tool can be launched by pressing F12 on the browser. Users can easily hover over any element and find its different HTML properties.<\/p>\n\n\n\n<p>Firebug is a plugin of Firefox that provides various development tools for debugging applications. From an automation perspective, Firebug is used specifically for inspecting web elements in order to find their attributes like id, class, name, etc. in different locators.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">45) What is an XPath?<\/h2>\n\n\n\n<p>Xpath or XML path is a query language that is used for selecting nodes from XML documents. Also, it is one of the locators supported by Selenium Webdriver.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">46) What is an absolute XPath?<\/h2>\n\n\n\n<p>An absolute XPath is a way of locating an element using an XML expression, beginning from the root node i.e. HTML node in the case of web pages.<\/p>\n\n\n\n<p>The main disadvantage of absolute XPath is that even if there is a slight change in the UI or any element then also whole XPath will fail.<br>Example \u2013 html\/body\/div\/div[2]\/div\/div\/div\/div[1]\/div\/input<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">47) How can we move to the parent of an element using XPath?<\/h2>\n\n\n\n<p>Using \u2018\/..\u2019 after the XPath expression of the child element, we can move to the parent of an element.<br>For example, the locator \/\/div[@id=\u201dchildId\u201d]\/.. will move to the parent of the div element with id value as \u2018childId\u2019.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">48) How can we move to the nth-child element using XPath?<\/h2>\n\n\n\n<p>Basically, there are two ways of navigating to the nth element using XPath-<\/p>\n\n\n\n<p>Using square brackets with index position-<br>Example \u2013 div[2] will find the second div element.<br>Using position()-<br>Example \u2013 div[position()=3] will find the third div element.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">49) What is the syntax of finding elements by id using CSS Selector?<\/h2>\n\n\n\n<p>By using #idValue in the CSS locator, we can select all the elements belonging to a particular class e.g. \u2018#userId\u2019 will select the element having an id \u2013 userId.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">50) How can we select elements by their attribute value using the CSS Selector?<\/h2>\n\n\n\n<p>Using [attribute=value] in the CSS locator, we can select all the elements belonging to a particular class e.g. \u2018[type=small]\u2019 will select the element having attribute type of value \u2018small\u2019.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Related video:<\/h4>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\"  id=\"_ytid_47271\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/MIazOFA7s98?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  epyt-is-override  no-lazyload\" title=\"YouTube player\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>1) What is Selenium and what is composed of? Selenium is a suite of tools for automated web testing. It is composed of Selenium IDE (Integrated Development Environment) : It is a tool for recording and playing back. It is a firefox pluginWebDriver and RC: It provide the APIs for a variety of languages like&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[52,10398],"tags":[1729,5825,420,310,1649,5454,585,357,1072,4467,4696,4459,588,268,766,3347,173,5611,3433,666,177,686,176,178,4890,779,311,637,5389,4301,182],"class_list":["post-28042","post","type-post","status-publish","format-standard","hentry","category-interview-questions-answers","category-selenium","tag-advantages","tag-android","tag-apache","tag-application","tag-automation","tag-chrome","tag-development","tag-driver","tag-environment","tag-firefox","tag-google","tag-html","tag-integration","tag-internet-explorer","tag-interview","tag-interview-questions-answers","tag-java","tag-javascript","tag-junit","tag-open-source","tag-php","tag-programming-language","tag-python","tag-ruby","tag-selenium","tag-testing","tag-tools","tag-top","tag-url","tag-versions","tag-windows"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/28042","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=28042"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/28042\/revisions"}],"predecessor-version":[{"id":28049,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/28042\/revisions\/28049"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=28042"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=28042"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=28042"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}