I have this html-Output:
<span>Sign in</span>
How can I use:
click_button I18n.t 'users.sign_in'
I think capybara can not find the button because of the span. What is the best solution to find and test the button?
Cheers
Why don't you use rails tag for submit?
Try <%= submit_tag I18n.t('.users.sign_in') %> and I think it will work.
Well, that is the corresponding .erb-Code:
<%= link_to content_tag(:span,I18n.t("users.sign_in")), "#", style: "margin-left:132px; margin-top:12px;", class: "button-submit-magenta", onclick: "$(this).parents('form:first').submit()" %>
I need the 'span' for compatibility with IE7.
It's not working because you don't have a proper link or button. This will work if you only have one element with the same class on the page:
page.find('.button-submit').click
Try this. Hope it'll work.
page.find(:xpath, "//span[text()='Sign in']").click
Related
I got a problem with a link I've tried to make. I want to have a page with an article, and a link to the author page of it. Iv's try 100 differents version but i don't know how to do...
Here is my code :
<a <% link_to " Par : #{#article.author.pseudo}", user_path(User.where(user_id: #author_id) %></a>
or with this path : user_path(Article.find(params[:id]).author_id)
If you know how I can resolve that... Thanks !
Don't wrap link_to helper into <a>tag, it is already generated by the helper. where returns the collection, not the instance - that's why your code does not work. You already have needed user instance in #article.author, just use it
<%= link_to "Par : #{#article.author.pseudo}", user_path(#article.author) %>
You should be able to link directly to the author:
<%= link_to "Par : #{#article.author.pseudo}", #article.author %>
Try something like this:
<%= link_to("Par : #{#article.author.pseudo}", #article.author) %>
I'm following along here: Text Helper
Specifically I'm using the last example and have in my code:
<%= truncate_html(posts.content) {link_to "Continue", post_path(posts.url_name)}%>
The first part of the truncate works but the link does not appear. Any idea why my link isn't appearing?
I don't know the truncate_html, but you could use this questions answer with a block in the end:
<%= truncate(posts.content, :escape => false) { link_to "Continue", post_path(posts.url_name) } %>
That would create the result you want.
truncate_html does not appear to be a valid method in the Rails base code. Try with truncate
<%= truncate(posts.content) {link_to "Continue", post_path(posts.url_name)}%>
link_to feed_item.votes_for + "Into it!", into_it_micropost_path(feed_item.id)
I basically want the hyperlink to be that variable next to the string "Into it!"
how can i achieve this? thanks
Actually it seems to me your version is supposed to work just fine.
Maybe try to put it in another way:
link_to "#{feed_item.votes_for} Into it!", into_it_micropost_path(feed_item.id)
Don't forget that for the link to appear you will have to put it inside <%= %>
I'm trying to convert an H3 header into a link. Here's the code of it
=link_to( "<H3>Home</H3>", root_url)
But it literally outputs the "Home" on my page. I'm using haml as view engine. Is there any way around?
Try this
=link_to(root_url) do
%h3 Home
Try
%h3= link_to("Home", root_url)
3rd solution is to use content_tag
At the moment
<%= link_to comment.file, comment.file_url %>
displays
/uploads/comment/file/6/IP___Addresses
Is there such thing as something like comment.file.filename ?
Is there a way to get the filename and display a link to that, so it would just say IPAddresses.txt and links to "/uploads/comment/file/6/IPAddresses" ?
Edit:
Figured it out
<%= link_to File.basename(comment.file.url), comment.file_url %>
You could have used the *_identifier method, in your case:
comment.file_identifier