Switching context does not work

below is the code snippet:

set_context “WEBVIEW_1”
within_context(‘WEBVIEW_1’) do
@driver.find_element(:id, “button-create-account”).click
end
set_context “NATIVE_APP”
within_context(‘NATIVE_APP’) do
@driver.find_element(:name, “icon close”).click
end
# sleep 2
set_context “WEBVIEW_1”
within_context(‘WEBVIEW_1’) do
@driver.find_element(:id, “button-create-account”).click
end

I am using appium 1.3.4 and above code looks okay to me but i still get Selenium::WebDriver::Error::NoSuchElementError: An element could not be located on the page using the given search parameters.

I am trying to interact with native and webview elements and thought this simple test should pass. Let me know if need more info.

Also notice the commented sleep. if i add sleep the test works.
NOTE: haven’t moved to 1.3.5 since could not get appium.io working

1 Like