简体   繁体   English

使用Selenium Webdriver的ExtJS测试自动化

[英]ExtJS Test Automation using Selenium Webdriver

I have questions on automating the test cases of an ExtJS application using the Selenium webdriver. 我对使用Selenium Webdriver自动化ExtJS应用程序的测试用例有疑问。

Two years back, I was asked to automate the same ExtJS application using HP UFT. 两年前,我被要求使用HP UFT自动化相同的ExtJS应用程序。 I did that by developing a custom UFT add-in for the ExtJS components. 我通过为ExtJS组件开发自定义UFT加载项来做到这一点。 Now I am asked to continue the automation but with selenium webdriver and not UFT. 现在,我被要求继续自动化,但要使用硒webdriver而不是UFT。 Today, I tried with a few controls and I see that Selenium fails to recognize a few controls like ExtJS tree node, ExtJS tab etc using the xpath. 今天,我尝试了一些控件,但发现Selenium无法使用xpath识别一些控件,例如ExtJS树节点,ExtJS选项卡等。

I see firepath takes me to the correct control when I type the locator value in it. 当我在其中输入定位器值时,我看到firepath将我带到了正确的控件。 But if I use the same locator value in my Java code, I get a nosuchelement exception thrown by Selenium. 但是,如果我在Java代码中使用相同的定位符值,则会收到Selenium抛出的nosuchelement异常。

Here is my code to select a particular node in the list. 这是我的代码,用于在列表中选择一个特定的节点。

<div>
    <span class="x-tree-node-text">Circuit</span>
</div>

By.xpath("//span[contains(text(),'Circuit')])[1]")   // there are two circuits like

Is my job of automating using Selenium going to be tough? 我使用Selenium进行自动化的工作会很难吗? I learnt only Java. 我只学过Java。 Should I learn new technologies to automate this app? 我应该学习使该应用程序自动化的新技术吗?

Please let me know. 请告诉我。

ExtJS is an animal when it comes to automating with Selenium. 在使用Selenium进行自动化时,ExtJS是一种动物。 I've done several ExtJS apps with nothing more than CSS and jquery selectors. 我完成了几个ExtJS应用程序,仅使用CSS和jquery选择器。 Jasmine is the recommended approach but I haven't investigated it as I haven't found the need. 推荐使用茉莉花,但由于未找到需要的方法,因此未进行调查。 If you include the sizzle library it will allow you to use jquery selectors which are very helpful. 如果包含sizzle库,它将允许您使用非常有用的jquery选择器。 To select the element you provided with jquery it would be: 要选择您随jquery提供的元素,它将是:

$("span.x-tree-node-text:contains('Circuit')")

I'm on my phone and can't provide links but look into adding sizzle to your framework. 我在用手机打电话,无法提供链接,但正在考虑为您的框架添加嘶嘶声。 It will greatly improve your success automating ExtJS. 这将大大提高您成功实现ExtJS自动化的成功。

Your provided selector isn't working because you are specifying id for a div/span with no id. 您提供的选择器不起作用,因为您正在为没有ID的div / span指定ID。

I also ran into timing issues with ExtJS, where Selenium wasn't waiting for the dom to finish loading before it would blowup. 我还遇到了ExtJS的计时问题,其中Selenium不在等待dom完成加载之前就崩溃了。 The solution was to add a wait for ExpectedConditions.visibilityofElementLocated. 解决方案是添加一个对ExpectedConditions.visibilityofElementLocated的等待。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM