capybara webkit flakiness claiming page has no content? - capybara-webkit

I've got a rails app with devise, and have an incredibly straight forward spec demonstrating the ability to sign out a user:
sign_in user
visit root_path
within('.nav-links') do
page.find('.icon.logout').click
end
within('form') do
expect(page).to have_field 'user_username'
expect(page).to have_field 'user_password'
end
This intermittently fails, claiming that there's no form element on the page...
Out of desperation, I changed the spec to actually look (and wait) for content:
expect(page).to have_content 'MY FOOTER'
within('form') do
expect(page).to have_field 'user_username'
expect(page).to have_field 'user_password'
end
And I get:
Failure/Error: expect(page).to have_content 'MY FOOTER'
expected to find text "MY FOOTER" in ""
Which is telling me there is no content at all on the page????????????????????
What?
This failure happens every 5 or so test runs. Does anyone have any idea why this sort of thing would happen? How is it that signing out every now and then results in a blank page? I can't ever get this to fail while watching it execute in the browser with selenium / chromedriver. It only seems to be failing with webkit.

Related

How to redirect to login page in EnvoyFilter using lua code?

I am new to Lua, below is my inline code for "EnvoyFilter". I have spent a couple of hours to search a few articles and posts. But, didn't find any suitable answer, hence posting this question.
The scenario is when I am getting a 503 error code I want to redirect to the login page.
function envoy_on_response(response_handle)
if response_handle:headers():get(":status") == "503" then
#TODO Redirect to http://login-page.com
end
end
Any help or suggestion would be helpful and appreciated.
[Working Answer]
function envoy_on_response(response_handle)
if response_handle:headers():get(":status") == "503" then
response_handle:headers():replace("content-type", "text/html")
response_handle:headers():replace(":status", "307")
response_handle:headers():add("location", "https://login-page.com")
end
end
You could use a 302 Found response to instruct the users browser to make a new request to the login page.
Something like this should work:
First add some logging to validate, that it's working.
Now replace the status field in the header and set it to 302.
Last add a location field to the header, which contains the url you want to redirect to.
function envoy_on_response(response_handle)
if response_handle:headers():get(":status") == "503" then
response_handle:logInfo("Got status 503, redirect to login...")
response_handle:headers():replace(":status", "302")
response_handle:headers():add("location", "http://login-page.com")
end
end
See docs for further inspiration: https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/lua_filter
Having said this I want to add that this might not be a good approach for failure handling. The user will not be informed about the error, but will just be redirected and land on the login page, without knowing why.
What problem are you trying to solve? Maybe there is a better way.

Facebook Custom Tabs

I understand how to create the app for the custom tab. However when I try to layout the next step it comes back with an error message. Can someone help me to properly layout the "With URL Redirects".
I know to put the Id number where is says YOUR APP ID and I have also placed the website in the "YOUR URL" position but it doesn't work. I have watched several videos and they all seem to be prior to the latest FB update.
The problem I am having seems to be coming from the setup for this code below that leads you to the Add Page Tab Dialog prompt. facebook.com/dialog/pagetab? app_id=YOUR_APP_ID &redirect_uri=YOUR_URL When I insert the "Your App ID" and Your URL" and hit enter I am receiving a Facebook Error message that says:
This dialog has been passed a bad parameter. API Error Code: 100 API
Error Description: Invalid parameter Error Message: Requires valid
redirect URI.

The Deezer's API page doesn't let me create a new app

I'm trying to create a new app on Deezer in this link but it doesn't let me, i put all the fields in the correct way and accept the policies, then i press "Create" but nothing happens, not even a error message, justo load a couple of seconds and nothing more. The Javascript console show me an error, it says "Uncaught ReferenceError: myapps is not defined" at line 199 on "create".
You have to fill full url with HTTP scheme (eg. http:// www.example.com) in these 3 fields:
Domain
Redirect URL after authentification
Link to your Terms of Use

click_no_wait and then execute_script

I'm using the page object gem with a page that contains a link.
When the link is clicked, the browser navigates to a new page, and the HTML renders as expected.
However, my script is always returning a Timeout::Error: Timeout::Error. After looking at the browser network activity, I noticed a pattern with a long running get that never completes.
If I run the script and then go to the console and issue the command
$.connection.hub.stop(), the script will not time out.
Is there a way to perform a click_no_wait or to click and then execute a script via the use of page_object_gem ?
Here is my page-object attempt, but it is resulting in a timeout still.
class MyThing
include PageObject
include PageObject::PageFactory
link(:show_details, :id => 'detailLink')
def click_show_details_no_wait
begin
show_details_element.click
rescue Exception => e
execute_script('$.connection.hub.stop();')
end
end
end
It is hard to suggest without your page. My first idea is to try to do
show_details_element.fire_event('click')
instead of a usual click.
The second idea is take a look at
Stop loading page watir-webdriver
Is there have method to stop page loading in watir-webdriver
how to click on browser “stop loading this page” using ruby watir?
Good luck.

Facebook Login throws "Permission denied"

I am adding Facebook login to my existing asp.net application. I have added a Facebook login button to my login screen. Now, I click Facebook's login button and in IE 9 it throws client-side exception in all.js on Line 22: if(a.params)b.fbCallID=a.id;
Even after that exception I see the Facebook login screen and can log in, and in the main browser window I get the auth.login event, so I can live with that.
But, if I am already logged in to Facebook, I come to the page and click Facebook login button, I briefly see the empty popup window, then I get teh same client-side exception, and then I get no event in the main browser window, so I don't know if the user logged in so I can't redirect them to another page.
I tried the channelUrl trick but it didn't help.
Any suggestions what's going on?
I found this hack that fixed the issue for me; add this line right after you call FB.init():
// Hack to fix http://bugs.developers.facebook.net/show_bug.cgi?id=20168 for IE7/8/9
FB.UIServer.setLoadedNode = function (a, b) {
FB.UIServer._loadedNodes[a.id] = b;
};
The reason it is happening (from the websites and documents I have read, and believe me, I've read a LOT) is that IE refuses cross-site javascript, and it sees the all.js as crossing the sandbox border. A good discussion can be found here.
Some people say that adding the channel.html file works, but we have tried all flavors of that, and have not had any success. (Remember that the http or https must match the page sending the request.)
Microsoft makes reference to this same issue and their advice is to add the site to trusted sites (that doesn't help). Old advice (from last year) is to add CP="HONK" as your compact privacy policy, but I think that bug was fixed, and it was cookie-related.
What seems to be happening to us is that the login actually continues, and the callback gets called properly, but the main thread that should complete outside of the login call stops executing (because of the error). So, any functions outside the login fail to execute after the login call.
If anyone has a way to get IE to not throw the exception or to create a workaround for this issue, I am desperate to have it. Any info needed I will be happy to provide, but a sample is here:
enter code here
code before login here...
FB.login(function(response){
callback stuff here... This part fires.
});
main thread stuff here... This fails because of permission denied error.