Fix issue with switching to the same frame twice in a row

This commit is contained in:
Thomas Walpole 2017-02-16 18:32:40 -08:00 committed by Matthew Horan
parent fd63a7eec3
commit 702bce9ce9
4 changed files with 20 additions and 2 deletions

View File

@ -83,7 +83,7 @@ module Capybara::Webkit
def frame_focus(selector=nil)
if selector.respond_to?(:base)
selector.base.invoke('focus')
selector.base.invoke("focus_frame")
elsif selector.is_a? Fixnum
command("FrameFocus", "", selector.to_s)
elsif selector

View File

@ -325,6 +325,16 @@ describe Capybara::Session do
end
end
end
it "can swap to the same frame multiple times" do
subject.visit("/")
subject.within_frame("a_frame") do
expect(subject).to have_content("Page A")
end
subject.within_frame("a_frame") do
expect(subject).to have_content("Page A")
end
end
end
context 'click tests' do

View File

@ -11,7 +11,7 @@ void Node::start() {
QString functionName = functionArguments.takeFirst();
QString allowUnattached = functionArguments.takeFirst();
InvocationResult result = page()->invokeCapybaraFunction(functionName, allowUnattached == "true", functionArguments);
if (functionName == "focus") {
if (functionName == "focus_frame") {
page()->setCurrentFrameParent(page()->currentFrame()->parentFrame());
}
finish(&result);

View File

@ -357,6 +357,14 @@ Capybara = {
this.getNode(index).focus();
},
focus_frame: function(index) {
var elem = this.getNode(index);
if (elem === document.activeElement) {
elem.blur();
}
elem.focus();
},
selectOption: function(index) {
var optionNode = this.getNode(index);
var selectNode = optionNode.parentNode;