http://www.softwaretestinghelp.com/locate-elements-in-chrome-ie-selenium-tutorial-7/
This is tutorial #7 in our Selenium Online Training Series. If you want to check all Selenium tutorials in this series please check this page.
In the previous tutorial, we tried to shed light on various types of locators in Selenium and their locating mechanisms to build test scripts. The tutorial was primary consist of the brief introduction of different locator types like ID, Classes, Xpaths, Link texts, CSS Selectors etc. and their identification.
Proceeding ahead with our next tutorial, we would take the opportunity to introduce you with an extension of locating strategies. Thus, in the next tutorial, we would study the mechanism to locate web elements on Google Chrome and Internet Explorer.
As we all are well aware of the fact that there is rapid growth in the internet user base, thus stakeholders and programmers are building web applications which are likely to work on most of the browsers. Thus, imagine a situation where your web application doesn’t support Firefox but works well for Chrome and Internet Explorer. Now how are you going to automate such an application using Selenium? Or to be specific how are you going to locate web elements in Chrome and Internet Explorer. Thus the answer lies ahead in this tutorial.
Locating Web Elements in Google Chrome
Let us begin with understanding the locating strategies in Google Chrome.
Like firebug in Firefox, Google Chrome has its own developer tool that can be used to identify and locate web elements on the web page. Unlike firebug, user is not required to download or install any separate plugin; the developer tool comes readily bundled with Google Chrome.
Follow the below steps to locate web elements using Chrome’s Developer tool:
Step #1: The primary step is to launch the Google Chrome’s Developer tool. Press F12 to launch the tool. The user would be able to see something like the below screen.
Take a note that “Element” tab is highlighted in the above screenshot. Thus, element tab is the one which displays all the HTML properties belonging to the current web page. Navigate to the “Element” tab if it is not opened by default on the launch.
You can also launch developer tool by right clicking anywhere within the web page and by selecting “Inspect element” which is very similar to that of firebug’s inspection.
Step #2: The next step is to locate the desired object within the web page. One way to do the same is to right click on the desired web element and inspect. The HTML property belonging to that web element would be highlighted in the developer tool. Another way is to hover through the HTML properties and the matching web element would be highlighted. Thus, in this way user can locate ids, class, links etc.
Creating an Xpath in Developer Tool
We have already discussed about Xpaths in the last tutorial. We also discussed about its creation strategy. Here we would base our discussion to check the validity of the created Xpath in Chrome’s Developer tool.
Step #1: For creating Xpath in Developer tool, open the console tab.
Step #2: Type the created Xpath and enclose it in $x(“//input[@id=’Email’]”)
Step #3: Press the enter key to see all the matching HTML elements with the specified Xpath. In our case, there is only one matching HTML element. Hover on that HTML element and the corresponding web element would be highlighted on the web page.
In this way, all the Xpaths can be created and checked for their validity within the console.
Information related to CSS corresponding to the web element can be found within the Chrome’s Developer tool. Refer the screenshot below:
------------
Locating Web Elements in Internet Explorer
Like Google Chrome, Internet Explorer also has its own Developer Toolthat can be used to identify web elements based on their properties within the web page. User is not required to download or install any separate plugin, the developer tool comes readily bundled with Internet Explorer.
Follow the below steps to locate web elements using IE Developer tool:
Step #1: The primary step is to launch the IE Developer tool. Press F12 to launch the tool. The user would be able to see something like the below screen.
Take a note that “HTML” tab is highlighted in the above screenshot. Thus, HTML tab is the one which displays all the HTML properties belonging to the current web page. Expand the HTML tab to view the properties of all the web elements belonging to the current web page.
Step #2: The next step is to locate the desired object within the web page. One way to this is to select the HTML element and the matching web element would be highlighted. Thus, in this way user can locate ids, class, links etc. Check out in the below screenshot in which Email Textbox would be highlighted as soon as we select the corresponding HTML property.
Another way to locate the web element is to click on the “Find” button present in the top menu and by clicking on the desired web element within the web page. As a result, the corresponding HTML properties would be highlighted.
Thus, by using the developer tool, user can find ids, classes, tag names and can create Xpaths to locate web elements.
Like Chrome’s Developer tool, IE developer tool has a separate section that displays CSS related information. Checkout the below screenshot.
Conclusion
In this tutorial, we shed light on the basic element locating strategies using Developer’s tool for Google Chrome and Internet Explorer.
Next Tutorial #8: Proceeding ahead with our next tutorial, we would take the pleasure to introduce you with a more advanced tool named as WebDriver. WebDriver is one of the most compelling automation testing tools. So our next tutorial onwards, we would route and base our discussions around WebDriver and all its nitty gritty
相关推荐
使用selenium与webdriver打交道,是启动webdriver去调用浏览器,来完成操作。这就是selenium-chrome-driver-3.14.0.jar,作为chrome浏览器的webdriver,被selenium调用执行操作。
【描述】"selenium-dotnet-2.46.0网上最新版C#嵌入chrome源码" 暗示了这个压缩包包含了Selenium WebDriver for .NET的源代码,特别针对Chrome浏览器的自动化测试进行了优化。C#开发者可以利用这些源码深入理解...
7. Download the selenium-client to c:\Ruby192\bin. The version I have downloaded was selenium-client 1.2.18 8. Set the CLASSPATH C:\Ruby192\bin – This is done by adding System Variables 9. Go to Cmd ...
标题 "selenium-server-standalone-4.0.0-alpha-2.zip" 指的是 Selenium 的一个服务器独立版本的归档文件,该版本为 4.0.0 的 Alpha 2 版本。Selenium 是一个广泛使用的自动化测试工具,主要用于 Web 应用程序的测试...
首先,我们来了解一下 `selenium-java-2.44.0.jar`。这是一个预编译的Java库,其中包含了Selenium WebDriver的Java绑定。WebDriver是Selenium的一个核心部分,它提供了一个编程接口,允许测试脚本直接控制浏览器。...
它的服务器独立版本,即 `selenium-server-standalone-3.0.0.jar`,是 Selenium 的核心组件之一,提供了远程控制浏览器的能力,支持多种浏览器如 Chrome、Firefox、IE 等。 该 JAR 包的版本号为 3.0.0,意味着它是 ...
selenium-server-standalone-2.44.0, selenium最新服务器,
selenium-chrome-driver-3.6.0.jar,chrome浏览器依赖包
selenium-server-standalone-3.141.59.jar selenium-server-standalone-3.141.59.jar
"selenium-server-standalone-2.45.0" 和 "selenium-java-2.45.0(含srcs)" 提供了Selenium在Java环境下的核心组件,以及一个独立的服务器版本,方便进行Web应用的自动化测试。 1. **Selenium Server Standalone**...
这个标题提到的是 "selenium-server-standalone-3.4.0" 和 "selenium-java-3.4.0.jar",它们是 Selenium 3.4 版本的组成部分,专为 Java 开发者设计。下面将详细阐述这两个文件及其在测试中的作用。 `selenium-...
这个压缩包 "selenium-java-2.47.1.zip" 包含了Selenium的Java版本,具体是2.47.1的更新,发布于2015年8月。这个版本在当时是一个稳定且广泛使用的版本,它提供了丰富的API,支持多种浏览器,并且可以与各种测试框架...
标题中的“selenium-java-2.25.0.zip”和“selenium-server-standalone-2.25.0.jar”是Selenium自动化测试框架的两个关键组件,分别代表了Selenium的Java绑定库和独立服务器。Selenium是一个开源的Web应用程序自动化...
8. **浏览器兼容性测试**: Selenium 支持多种浏览器,如 Chrome、Firefox、IE 等,可进行跨平台和跨浏览器测试。 掌握这些知识点,开发者可以有效地利用 Selenium 进行 Web 应用的自动化测试,提高测试质量和效率。...
在本主题中,我们将深入探讨`selenium-java-2.41.0`和`selenium-java-2.33.0`这两个版本。 首先,`selenium-java-2.33.0.zip`和`selenium-java-2.41.0.zip`是两个不同版本的Selenium Java绑定包。这些zip文件包含了...
selenium3.9.0-server-standalone.jar文件,需要的赶紧下载了
selenium-server-standalone-2.53.1.jar用于支持selenium webdriver的开发,也可用于分布式测试连接
通常,这包括如 selenium-server-standalone-3.141.59.jar、selenium-java-3.141.59.jar 等文件,它们包含了执行自动化测试所需的所有依赖。 在使用 Selenium WebDriver 进行测试时,首先需要选择一个浏览器驱动...
【Selenium-Java 3.7.1.jar】是一个关键组件,主要用于自动化Web应用程序的测试。这个特定的版本,3.7.1,是Selenium WebDriver的一个Java绑定,它允许开发者使用Java语言来编写测试脚本,从而实现对浏览器的自动化...