我正在尝试在 2 帧内执行某些操作,但每次尝试在帧之间切换时都会出现错误。例如:
# encoding: utf-8
require "capybara/dsl"
Capybara.run_server = false
Capybara.current_driver = :selenium
Capybara.app_host = 'https://hb.posted.co.rs/posted'
class Account
include Capybara::DSL
def check_balance
visit('/')
page.driver.browser.switch_to.frame 'main'
fill_in 'korisnik', :with => 'foo'
fill_in 'lozinka', :with => 'bar'
click_button 'Potvrda unosa'
page.driver.browser.switch_to.frame 'header'
click_on 'Stanje'
end
end
account = Account.new
account.check_balance
错误是:
[远程服务器] file:///tmp/webdriver-profile20120810-9163-xy6dtm/extensions/fxdriver@googlecode.com/components/driver_component.js:6638:in `unknown': 无法定位框架:main (Selenium:: WebDriver::Error::NoSuchFrameError)
问题是什么?也许我在这里做错了什么?
如果我更改切换帧的顺序,那么首先尝试切换到“标题”然后切换到“主”帧,然后会出现同样的错误,只是它说这次没有“主”帧:
# encoding: utf-8
require "capybara/dsl"
Capybara.run_server = false
Capybara.current_driver = :selenium
Capybara.app_host = 'https://hb.posted.co.rs/posted'
class Account
include Capybara::DSL
def check_balance
visit('/')
page.driver.browser.switch_to.frame 'header'
click_on 'Stanje'
page.driver.browser.switch_to.frame 'main'
fill_in 'korisnik', :with => 'foo'
fill_in 'lozinka', :with => 'bar'
click_button 'Potvrda unosa'
end
end
account = Account.new
account.check_balance
错误:
[远程服务器] file:///tmp/webdriver-profile20120810-9247-w3o5hj/extensions/fxdriver@googlecode.com/components/driver_component.js:6638:in `unknown': 无法定位框架:main (Selenium:: WebDriver::Error::NoSuchFrameError)