0

正在工作但添加条件链接的 Watir 代码在这里没有再次识别:(

require 'spec'
require 'watir'

browser = Watir::Browser.new 
pages = { "RCM Workspace Homepage" => "http://rcm-bpmt.apmoller.net/workspace/faces/jsf/workspace/workspace.xhtml" }

Given(/^that I am on the (.*?)$/) do |page|
  # Opening new browser and going to the page which is specified
  browser.goto(pages[page])

  #Maximizing the opened browser window
  browser.maximize
end

When(/^I search for (.*?)$/) do |text|
  # Ensuring that we have opened expected page only by verifying the page content 
  browser.html.include?(text).should == true 
end

Then(/^I click on Show Filters link$/) do
  #Opening the Conditions window by clicking on the show filters link 
  browser.link(:id, "portletComponentWorkList_viewNormalModeWorkList_viewPanel_showFiltersLink").click

  #Clicking on Add condition link which is placed in a frame and it opnes when I click on Show filters link
  browser.element(:id, 'portletComponentWorkList_viewNormalModeWorkList_viewPanel_conditionButton').click
end

HTML 详细信息:

<A id=portletComponentWorkList_viewNormalModeWorkList_viewPanel_conditionButton onclick="oc.ajax.jsf.doCallback('portletComponentWorkList','portletComponentWorkList:viewNormalModeWorkList:viewPanel:conditionButton');return false;" href="http://rcm-bpmt.apmoller.net/workspace/faces/jsf/workspace/workspace.xhtml#">
  Add condition
</A>
4

1 回答 1

0

在下一行中,Watir 将在框架之外的任何地方查找元素。

browser.element(:id, 'portletComponentWorkList_viewNormalModeWorkList_viewPanel_conditionButton').click

与其他元素不同,当元素在框架中时,您必须告诉 Watir。这与将元素搜索范围限定到特定元素的方式类似。

例如,如果只有一帧或者您的元素在第一帧中,您可以这样做(注意添加.frame):

browser.frame.element(:id, 'portletComponentWorkList_viewNormalModeWorkList_viewPanel_conditionButton').click

如果有多个框架,您将需要添加参数以更具体地确定要使用的框架。例如,如果框架有一个 id:

browser.frame(:id => 'myframe').element(:id, 'portletComponentWorkList_viewNormalModeWorkList_viewPanel_conditionButton').click
于 2013-10-28T16:10:20.900 回答