Selenium: 空指针error

Error 类型:空指针

可能原因一:

只是引用了该类,但是没有对该类进行实例化(即没有New 一下),即没有给该类分配内存,所以导致空指针;

类调用前注意要实例化,否则会导致空指针错误.

首先声明DashboardPage类型的引用,然后创建DashboardPage类型的对象,然后访问DashboardPage 类中的menuDashboardPage 属性

public static DashboardPage dashboard;

helper = new TestHelper();
dashboard = (DashboardPage) helper.getPage("DashboardPage");

driver.findElement(By.xpath(dashboard.menuOnDashboard.xpath)).click();

可能原因二:

该元素的xpath为空,需检查对应的CSV文件里该元素的xpath

时间: 2025-01-18 04:58:21

Selenium: 空指针error的相关文章

Selenium::WebDriver::Error::WebDriverError:Unable to find standalone executable解决办法

情况描述: 在Watir-Webdriver环境下运行脚本报错(红色标记部分): C:\>irbirb(main):001:0> require 'watir-webdriver'=> trueirb(main):002:0> Watir::Browser.new :ieSelenium::WebDriver::Error::WebDriverError: Unable to find standalone executable. Please download the IEDri

解决Ruby在IE11中报Unable to get browser (Selenium::WebDriver::Error::NoSuchWindowError)的错误

转载地址:http://www.tuicool.com/articles/BRnqeu2 I was updating the browser WebDrivers for    Seleno    when I hit an issue with the InternetExplorerDriver. I was running Selenium WebDriver 2.43.1 on Windows 8.1 and using Internet Explorer 11. The test w

Quick solution to java.lang.NoClassDefFoundError: org/openqa/selenium/HasInputDevices error

In case if you face this problem, one of the possible solutions that will work for you is to make sure that your pom.xml file is up to date and you use right version of webdriver and selenium java bindings. Here's what helped me <dependency> <gro

selenium无法调用chrome或者firefox的原因

现在我们用的开源工具一般为selenium,当然其中的好处是可以调用不同的浏览器.包含了ie\google\firefox等等,但调用的时候会出现无法调用其浏览器.原因很简单,selenium和其浏览器的版本不符合.一般情况下是selenium调用的各个DRIVER版本低于浏览器的版本引起. 具体情况: C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.43.0/lib/selenium/webdr iver/remote/resp

selenium docs

Note to the Reader - Docs Being Revised for Selenium 2.0! Introduction Test Automation for Web Applications To Automate or Not to Automate? Introducing Selenium Brief History of The Selenium Project Selenium’s Tool Suite Choosing Your Selenium Tool S

scrapy和selenium结合抓取动态网页

1.安装python (我用的是2.7版本的) 2.安装scrapy:   详情请参考 http://blog.csdn.net/wukaibo1986/article/details/8167590 (提示,能下载源码安装的就避免用pip install **) 安装过程中遇到python扩展问题”unable to find vcvarsall.bat“的解决办法: http://blog.csdn.net/ren911/article/details/6448696 3.安装seleniu

如何提高UI自动化测试的质量

背景 项目是基于Ruby on Rails开发的web程序,应该说项目中的测试实践是很好的,具有高覆盖率的单元测试以及比较合理的集成测试.存在的问题是,所有的单元测试和集成测试都是针对后端代码的,前端的JavaSript代码没有单元测试(这个是有历史原因的,暂时没法改变).这也就意味着针对前端UI的修改是没有底层的单元测试来保障的,只能依靠高层级的UI自动化测试和手工测试来保障. 我们最近刚刚完成了一个story,是纯前端的开发工作,结果在上线后发现我们在修改页面模板文件时,忘记了其他地方也在使

一个有意思的Ruby Webdriver超时问题的解决过程

rescue in receive 由于写ruby的时候感觉混身上下都拽起来了,所以比較喜欢用ruby写代码. 今天遇到了一个webdriver timeout的问题,问题本身还是由于我对webdriver不了解以及破文档导致的.首先我们把问题简化一下: driver = Selenium::WebDriver.for :safari driver.navigate.to "http://www.faraway.com" wait = Selenium::WebDriver::Wait

解决Firefox浏览器每次打开都弹出导入向导的问题

每次打开Firefox浏览器都会弹出导入向导这个页面,只有这个页面关闭后,Firefox界面才会打开. 解决办法: C:\Users\{用户名}\AppData\Roaming\Mozilla\Firefox\profiles.ini 把profiles.ini文件中IsRelative=1修改为IsRelative=0 报错: in `connect_until_stable': unable to obtain stable firefox connection in 60 seconds