I was implementing capybara for a app flow. I have features/step_definitions/anonymous_booking_steps.rb with two steps
for just visiting the root path
expecting an element in next step for the above page
I am getting this error:-
Unable to find xpath "/html" (Capybara::ElementNotFound)
Related
Error LogsTrying to click on an element XPath not working. I have used several other XPath in my application. All other working expect this!
driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/androidx.drawerlayout.widget.DrawerLayout/android.view.ViewGroup/android.widget.RelativeLayout/androidx.viewpager.widget.ViewPager/android.view.ViewGroup/android.widget.FrameLayout/android.widget.LinearLayout/android.view.ViewGroup/android.view.ViewGroup/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout2/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.widget.RelativeLayout2").click()
When creating an empty page in Confluence, wheel keeps spinning, I see following error in browser. Do you have any idea what is wrong?
TypeError: e.replace is not a function. (In 'e.replace(n,"⌘")', 'e.replace' is undefined)
I am trying to use Koala gem to publish custom open graph stories to the Facebook timeline of the users of my Rails application. The application has already been approved to publish this custom story batalharia:battle, but when I try to share the user story there is the following error:
Koala::Facebook::ClientError (type: OAuthException, code: 100, error_subcode: 1611008, message: Invalid parameter, error_user_title: Object Missing a Required Value, error_user_msg: Object at URL 'https://batalharia.com/pt-BR/battles/27' of type 'website' is invalid because a required property 'og:title' of type 'string' was not provided. [HTTP 400]):
app/controllers/users/omniauth_callbacks_controller.rb:95:in `share_battle_on_facebook'
app/controllers/users/omniauth_callbacks_controller.rb:19:in `facebook'
The error message says that the type is website and that og:title was not provided, but my page is configured with og:type with batalharia:battle and og:title was provided.
The page I am trying to share is this one: https://batalharia.com/battles/27
And the Koala code is:
def share_battle_on_facebook(credentials, battle_id)
#graph = Koala::Facebook::API.new(credentials.token)
#graph.put_connections("me", "batalharia:create", battle: battle_url(battle_id))
end
Has someone faced this problem and knows how to fix it?
Any help would be extremely appreciated.
Edit:
If I fetch new scrape information for the page in the facebook developers debug page, I get this error:
Meta Tags In Body: Your page has meta tags in the body instead of the
head. This may be because your HTML was malformed and they fell lower
in the parse tree. Please fix this in order for the tags to be usable.
But the meta tags are in head and the HTML is ok. Despite the error pointed out, the tags are correctly identified and parsed by the debug page.
I want to understand what the following Capybara syntax means -
find(:xpath, '//*[#id="application-lines"]/div[2]/ul/li[2]/a').click
I particularly don't understand the second attribute of the find method.
It would be great if someone could help me understand the syntax!
That is not something specific of Capybara, that is an XPath, is used to navigate the elements of an XML document.
In this case is looking for a node with id application-lines and inside that element retrieving the second div[2], with an ul element from which retrieves the second li and retrieves the a element inside it. All this ends up doing is a click on the a element found.
You can learn about XPaths here: XPath tutorial
For some reason when I do this:
click_on("Save")
My Capybara detects both:
<button>Save</button>
<button>Save & Schedule</button>
And so it gives "ambiguous match: 2 elements found" error.
Is there a way to tell it to do exact match?
No, there is no way to do that. You have to add uniq ids for these buttons since capybara 2.0 rises an error if more than one element was found.