Graphene 2.0.0.Alpha4,Selenium 的 Ajax 测试扩展

简介:

Graphene 2.0.0.Alpha4 发布了,Graphene 项目的目的是使用类型安全的 API 进行 Ajax 测试,是 Selenium 项目的扩展。

该版本值得关注的改进有:

Highlighted Changes

Guard Improvements and Fixes
Request Guards were polished, extended and hardened. (read more)

Creating Page Fragments Programatically
Page Fragments can now be instantiated not only using dependency injection, but also programatically. (read more)

PhantomJS Support
You can now fully leverage awesomness of headless testing with PhantomJS.

Guarding Programatically Retrieved Elements
Elements retrieved programatically using WebElement#findElement(...) or WebElement#findElements(...) are now guarded against StaleElementReferenceException.

Automatic Inference of Locators
You no longer need to define a locator in simple forms – you can leverage their automatic inference from a injection point name. (read more)

Dependency Injection of SessionStorage and LocalStorage
These resources are now exposed directly via @ArquillianResource.

Dependency Injection of Selenium Resource Parametrized by WebElement
Selenium resources which takes WebElement as an argument in a constructor (e.g. Select) can be injected using FindBy.

Support for FindBys and FindBy(How, String)

Improved Integration with Drone
Drone 1.2.0.Alpha2’s new Enhancer API allow us to integrate with Drone seamlessly.

Deprecations

Deprecation of Old Variant of Waiting Fluent API
Graphene.element(...) and Graphene.attribute(...) are now deprecated and they will be removed in an upcoming releases.

Deprecated guardXhr replaced by guardAjax
Not all of us are familiar with abbreviation XHR (XMLHttpRequest). In order to make the API more clear for most of Graphene users, we have deprecated guardXhr and replaced it with guardAjax. guardXhr will be removed in upcoming releases.

Guard Improvements and Fixes

waitForHttp
When an Ajax request is followed by a relocation (HTTP request), guardXhr or guardHttp can’t deterministically wait for an end of a request – in these situations you can use waitForHttp instead.

Testing delayed requests
Guards now waits for a given time interval for a request to start and once the request is started, they wait the another interval for the request to finish.

Bug Fixes
Guards had problems on Android with deterministic waiting for HTTP requests.

Creating Page Fragments Programatically

Till this release, the only option to create a page fragment was injecting it:

@FindBy(...)
      MyComponent component;

With Alpha4 we have added the possibility to create a page fragment programatically:

public  T getContent(Class clazz) {
          return PageFragmentEnricher.createPageFragment(clazz, root);
      }
@Test
      public void testTabPanelSwitching() {
          Panel tab3 = tabPanel.switchTo(2);
          ContentOfTab content = tab3.getContent(ContentOfTab.class);
          assertEquals("The tab panel was not switched to third tab correctly!", "Content of the tab 3", content.text.getText());
          
          Panel tab1 = tabPanel.switchTo(0);
          content = tab1.getContent(ContentOfTab.class);
          assertEquals("The tab panel was not switched to first tab correctly!", "Content of the tab 1", content.text.getText());
      }

You can find reference usage in this functional test together with an implementation of #getContent(Class).

Automatic Inference of Locators

How many times you have written:

// look for input with a name 'firstname'
      @FindBy(name = "firstname")
      private WebElement firstname;

You can now simplify your tests to just

@FindBy
      private WebElement firstname;

Graphene will automatically use the strategy How.ID_OR_NAME to locate the element by its ID or name.

Since this mechanism uses the strategy pattern, you can overwrite the default strategy for your test suite and therefore find elements by e.g. their class names or even JSF component IDs.

Roadmap

This release is a maintanance release on the way to Beta1.

What is Arquillian?

Arquillian is open source software that empowers you to test JVM-based applications more effectively. Created to defend the software galaxy from bugs, Arquillian brings your test to the runtime so you can focus on testing your application's behavior rather than managing the runtime. Using Arquillian, you can develop a comprehensive suite of tests from the convenience of your IDE and run them in any IDE, build tool or continuous integration environment.

Release details


b4079cb070b2aa4dedbb5844f058edde81e109ce

Published artifacts org.jboss.arquillian.graphene

  • org.jboss.arquillian.graphene » graphene-build-resources jar pom
  • org.jboss.arquillian.graphene » graphene-component-api jar pom
  • org.jboss.arquillian.graphene » graphene-selenium-api jar pom
  • org.jboss.arquillian.graphene » graphene-selenium-drone jar pom
  • org.jboss.arquillian.graphene » graphene-selenium-ftest-junit-container jar pom
  • org.jboss.arquillian.graphene » graphene-selenium-ftest-junit-standalone jar pom
  • org.jboss.arquillian.graphene » graphene-selenium-ftest-testng-container jar pom
  • org.jboss.arquillian.graphene » graphene-selenium-ftest-testng-standalone jar pom
  • org.jboss.arquillian.graphene » graphene-selenium-impl jar pom
  • org.jboss.arquillian.graphene » graphene-webdriver-ftest jar pom
  • org.jboss.arquillian.graphene » graphene-webdriver-impl jar pom
  • org.jboss.arquillian.graphene » graphene-webdriver-spi jar pom

Release notes and resolved issues 20

Q1/13: PhantomJS

Bug

  • ARQGRA-257 - Guards are not working with AndroidDriver
  • ARQGRA-262 - Element click with HTTP guard causes WebDriverException: ReferenceError: Graphene is not defined
  • ARQGRA-266 - Waiting for presence of element defined by jQuery selector sometimes causes "IllegalStateException: JQueryPageExtension can't be installed"
  • ARQGRA-272 - Introduced waitForHttp (guardXhr does not work for redirected pages)
  • ARQGRA-274 - The request guard does timeout for delayed requests
  • ARQGRA-289 - JavaScript interfaces fails on Chrome and PhantomJS
  • ARQGRA-290 - testAttributeIsPresent fails on Chrome and PhantomJS

Enhancement

  • ARQGRA-199 - Provide a way to create Page Fragments dynamically
  • ARQGRA-235 - Automatically infer ID locator from field name annotated just by @FindBy
  • ARQGRA-250 - Shortcut for waiting on element's attribute value

Feature Request

  • ARQGRA-220 - Locating elements with @FindBy(how = How.ID, using = "foobar") not working
  • ARQGRA-247 - Add support for enriching @FindBys annotations
  • ARQGRA-254 - Expose LocalStorage and SessionStorage enrichments directly
  • ARQGRA-258 - Provide injecting classes requiring WebElement in their constructors via @FindBy annotation
  • ARQGRA-259 - Provide timeout setting in fluent API
  • ARQGRA-273 - Intercept WebDriver to return proxies in findElement()/findElements() methods

Story

  • ARQGRA-286 - Support PhantomJSDriver in Graphene

Task

  • ARQGRA-168 - Create QUnit tests for Graphene.Page.RequestGuard.js
  • ARQGRA-284 - Rename guardXhr to guardAjax
  • ARQGRA-287 - Deprecate Graphene.element and attribute methods
相关文章
|
6天前
|
Web App开发 JavaScript 前端开发
《手把手教你》系列技巧篇(三十九)-java+ selenium自动化测试-JavaScript的调用执行-上篇(详解教程)
【5月更文挑战第3天】本文介绍了如何在Web自动化测试中使用JavaScript执行器(JavascriptExecutor)来完成Selenium API无法处理的任务。首先,需要将WebDriver转换为JavascriptExecutor对象,然后通过executeScript方法执行JavaScript代码。示例用法包括设置JS代码字符串并调用executeScript。文章提供了两个实战场景:一是当时间插件限制输入时,用JS去除元素的readonly属性;二是处理需滚动才能显示的元素,利用JS滚动页面。还给出了一个滚动到底部的代码示例,并提供了详细步骤和解释。
29 10
|
14天前
|
Java 测试技术 Python
《手把手教你》系列技巧篇(三十六)-java+ selenium自动化测试-单选和多选按钮操作-番外篇(详解教程)
【4月更文挑战第28天】本文简要介绍了自动化测试的实战应用,通过一个在线问卷调查(<https://www.sojump.com/m/2792226.aspx/>)为例,展示了如何遍历并点击问卷中的选项。测试思路包括找到单选和多选按钮的共性以定位元素,然后使用for循环进行点击操作。代码设计方面,提供了Java+Selenium的示例代码,通过WebDriver实现自动答题。运行代码后,可以看到控制台输出和浏览器的相应动作。文章最后做了简单的小结,强调了本次实践是对之前单选多选操作的巩固。
24 0
|
3天前
|
前端开发 Java 测试技术
《手把手教你》系列技巧篇(四十二)-java+ selenium自动化测试 - 处理iframe -下篇(详解教程)
【5月更文挑战第6天】本文介绍了如何使用Selenium处理含有iframe的网页。作者首先解释了iframe是什么,即HTML中的一个框架,用于在一个页面中嵌入另一个页面。接着,通过一个实战例子展示了在QQ邮箱登录页面中,由于输入框存在于iframe内,导致直接定位元素失败。作者提供了三种方法来处理这种情况:1)通过id或name属性切换到iframe;2)使用webElement对象切换;3)通过索引切换。最后,给出了相应的Java代码示例,并提醒读者根据iframe的实际情况选择合适的方法进行切换和元素定位。
7 0
|
3天前
|
Java 中间件 测试技术
深入理解自动化测试框架Selenium的设计与实现
【5月更文挑战第10天】 本文旨在深度剖析自动化测试工具Selenium的核心架构与实现机制,通过对其设计理念、组件结构以及在实际软件测试中的应用进行详细解读,使读者能够全面理解Selenium在现代Web应用测试中的重要性和有效性。文章首先介绍Selenium的发展背景及其解决的问题,然后详细探讨其架构设计,包括各种驱动和API的作用,最后结合实际案例分析Selenium如何提高测试效率和准确性。
|
4天前
|
前端开发 测试技术 Python
《手把手教你》系列技巧篇(四十一)-java+ selenium自动化测试 - 处理iframe -上篇(详解教程)
【5月更文挑战第5天】本文介绍了HTML中的`iframe`标签,它用于在网页中嵌套其他网页。`iframe`常用于加载外部内容或网站的某个部分,以实现页面美观。文章还讲述了使用Selenium自动化测试时如何处理`iframe`,通过`switchTo().frame()`方法进入`iframe`,完成相应操作,然后使用`switchTo().defaultContent()`返回主窗口。此外,文章提供了一个包含`iframe`的HTML代码示例,并给出了一个简单的自动化测试代码实战,演示了如何在`iframe`中输入文本。
14 3
|
5天前
|
JavaScript 前端开发 Java
《手把手教你》系列技巧篇(四十)-java+ selenium自动化测试-JavaScript的调用执行-下篇(详解教程)
【5月更文挑战第4天】本文介绍了如何使用JavaScriptExecutor在自动化测试中实现元素高亮显示。通过创建并执行JS代码,可以改变元素的样式,例如设置背景色和边框,以突出显示被操作的元素。文中提供了一个Java示例,展示了如何在Selenium中使用此方法,并附有代码截图和运行效果展示。该技术有助于跟踪和理解测试过程中的元素交互。
8 0
|
5天前
|
Web App开发 前端开发 JavaScript
自动化测试 selenium基础
自动化测试 selenium基础
11 2
|
7天前
|
JavaScript 前端开发 测试技术
《手把手教你》系列技巧篇(三十八)-java+ selenium自动化测试-日历时间控件-下篇(详解教程)
【5月更文挑战第2天】在自动化测试过程中,经常会遇到处理日期控件的点击问题。宏哥之前分享过一种方法,但如果输入框是`readonly`属性,这种方法就无法奏效了。不过,通过修改元素属性,依然可以实现自动化填写日期。首先,定位到日期输入框并移除`readonly`属性,然后使用`sendKeys`方法输入日期。这样,即使输入框设置了`readonly`,也能成功处理日期控件。
24 1
|
8天前
|
Java 测试技术 Python
《手把手教你》系列技巧篇(三十七)-java+ selenium自动化测试-日历时间控件-上篇(详解教程)
【5月更文挑战第1天】该文介绍了使用Selenium自动化测试网页日历控件的方法。首先,文章提到在某些Web应用中,日历控件常用于选择日期并筛选数据。接着,它提供了两个实现思路:一是将日历视为文本输入框,直接输入日期;二是模拟用户交互,逐步选择日期。文中给出了JQueryUI网站的一个示例,并展示了对应的Java代码实现,包括点击日历、选择日期等操作。
30 0
|
13天前
|
敏捷开发 监控 测试技术
探索自动化测试工具Selenium Grid的高效集成策略
【4月更文挑战第30天】在现代Web应用的快速迭代和持续部署中,测试自动化已成为确保产品质量的关键。Selenium Grid作为一款支持多种浏览器和操作系统的测试工具,提供了并行执行测试用例的能力,极大地提升了测试效率。本文将深入探讨如何高效地将Selenium Grid集成到现有的测试框架中,以及实施过程中的最佳实践,帮助团队最大化测试覆盖率,同时降低资源消耗。

热门文章

最新文章