`
guiven
  • 浏览: 28802 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Locator performance & considerations

 
阅读更多

When Doing Selenium tests, to locate the certain web elements, there are several methods.

Like By.id, By.className, By.tagName, By.name... But among them all, we use By.xPath and By.cssSelector to specify the elements with complex structure in the web page.


Now, while we are writing script to find and locate those web elements, we should be aware of the differences of these two "locating stratogy".


There are  four reasons for using CSS Locators: 

1. They’re faster
2. They’re more readable
3. CSS is jQuery’s locating strategy
4. No one else uses XPATH anyways!

 

 the speed of XPath vs the speed of CSS Locators can be viewed in performance metric script .

There wasn’t much of a difference in Firefox, Safari, or Chrome, but with IE, the results were undeniable. Take a look:


 there is a tool called  cssify It does the handy work of translating your XPaths to CSS automatically.


Is there any case  when you shouldn’t use CSS Locators (yes, there are a few cases where it is not the right tool for the job). 

 

You should see this 

CSS SELECTORS AND PSEUDO SELECTORS BROWSER COMPATIBILITY 


The above picture shows many selector Usage are not supported before IE9 version and firefox 4 version. When writing cssSelectors we should take these into account.

  • 大小: 65.5 KB
  • 大小: 44.4 KB
分享到:
评论

相关推荐

    osgi-resource-locator-1.0.1-API文档-中文版.zip

    赠送jar包:osgi-resource-locator-1.0.1.jar; 赠送原API文档:osgi-resource-locator-1.0.1-javadoc.jar; 赠送源代码:osgi-resource-locator-1.0.1-sources.jar; 赠送Maven依赖信息文件:osgi-resource-locator...

    Laravel开发-locator

    在本文中,我们将深入探讨Laravel开发中的"locator"项目,这是一个简单的本地路由器。通过理解这个项目,我们可以学习到Laravel框架的核心概念以及如何构建自定义的路由解决方案。首先,让我们了解一下Laravel。 ...

    如何解决NI service locator is not running

    安装labview之后,如何解决NI service locator is not running

    hk2-locator-2.4.0-b34-API文档-中英对照版.zip

    赠送jar包:hk2-locator-2.4.0-b34.jar; 赠送原API文档:hk2-locator-2.4.0-b34-javadoc.jar; 赠送源代码:hk2-locator-2.4.0-b34-sources.jar; 赠送Maven依赖信息文件:hk2-locator-2.4.0-b34.pom; 包含翻译后...

    Distribution Locator

    "分布定位器"(Distribution Locator)是一种在分布式系统中用于协调和管理资源分布的组件。简单来说,它是一个轻量级的分布协调器实现,旨在高效地帮助各个节点找到其所需的服务或数据在集群中的位置。这样的系统...

    element-locator-for-webdriv

    本文将深入探讨“element-locator-for-webdriv”这一Firefox插件,它是Selenium自动化测试中的对象识别神器,对于提高测试效率有着显著的作用。 首先,让我们了解一下Selenium。Selenium是一个开源的Web应用程序...

    osgi-resource-locator-1.0.1-API文档-中英对照版.zip

    赠送jar包:osgi-resource-locator-1.0.1.jar; 赠送原API文档:osgi-resource-locator-1.0.1-javadoc.jar; 赠送源代码:osgi-resource-locator-1.0.1-sources.jar; 赠送Maven依赖信息文件:osgi-resource-locator...

    selenium_webdriver_element_locator-1.rev312-fx.xpi

    selenium xpath webdriver_element locator webdriver_element_locator-1.rev312-fx.xpi work with firefox version 19-37

    oracle.jdbc-driver-locator.jar

    oracle.jdbc-driver-locator.jar

    webjars-locator-core:Webjars-locator 核心功能

    WebJarAssetLocator locator = new WebJarAssetLocator(); String fullPathToRequirejs = locator.getFullPath("require.js"); 获取基本文件夹中的所有资产 WebJarAssetLocator locator = new WebJarAssetLocator...

    IP locator

    这是一个互联网根据IP和域名定位的源代码,可以根据IP地址和制定域名获取相关的信息,如所属国家、地区、时区、互联网服务提供商(Isp)、经纬度等。同时利用Google地图自动显示该IP所处的地理位置。...

    Autofac的ServiceLocator模式应用,零配置

    总结来说,Autofac的ServiceLocator模式应用结合零配置,使得我们可以更轻松地管理和解耦应用程序中的组件。通过自动扫描、特性注解和模块化,我们可以减少大量手动配置,同时保持代码的清晰和可维护性。在`...

    Locator.exe

    Locator

    wifi locator 破解wifi密码软件

    wifi破解 专用软件

    Firefox浏览器xpath插件webdriver_element_locator-1.rev312-fx.xpi

    `webdriver_element_locator-1.rev312-fx.xpi` 是这个特定XPath插件的文件名,它表明这是一款与WebDriver相关的元素定位工具。WebDriver是一个开源的自动化测试框架,广泛用于网页应用的端到端测试。 XPath(XML ...

    hk2-locator-2.4.0-b34-API文档-中文版.zip

    赠送jar包:hk2-locator-2.4.0-b34.jar; 赠送原API文档:hk2-locator-2.4.0-b34-javadoc.jar; 赠送源代码:hk2-locator-2.4.0-b34-sources.jar; 赠送Maven依赖信息文件:hk2-locator-2.4.0-b34.pom; 包含翻译后...

    swift-Locatable是一个Swift微框架它利用PropertyWrappers通过自定义属性@Locatable实现ServiceLocator模式

    Swift-Locatable是一个专门针对Swift编程语言设计的微框架,其核心在于利用Swift的Property Wrappers特性,为开发者提供了一种简洁、高效的方式来实现Service Locator设计模式。Service Locator模式是一种常用的依赖...

    前端开源库-catberry-locator

    在`catberry-locator-master`压缩包中,包含了`catberry-locator`的源代码。通过查看这些源代码,我们可以深入理解其实现方式和工作原理: 1. `src/index.js`:这是库的主要入口点,定义了定位器类及其主要方法,如...

    Domain IP Locator v1.2

    检索IP所在地/查询域名归属是我们上网过程中经常打交道的一桩事,也许您已为此在收藏夹中准备了不少相关的查询网站、或是同时安装了多款 Whois 客户端等,而 Domain IP Locator 正是为提高您完成这些日常操作的效率...

Global site tag (gtag.js) - Google Analytics