How to avoid loss of driver object? - watir-webdriver

i am trying to migrate our test automation from watir-classic to watir-webdriver. (Ruby 2.0, watir-webdriver 0.9.1)
Which is working fine in general, but our login process gives me a headache.
Lets me short explain what happens:
Open Website A
Enter login credentials and press login button.
Website B is opened with the actual content while Website A is closed.
With the closing of Website A, the driver is also lost, i currently i cannot make a new instance of the driver to connect to the Website B.
when i try to do create an instance of the following pageobject, i get :
variable name="#exception" kind="instance" value="Unable to get
browser" type="Selenium::WebDriver::Error::NoSuchWindowError"
I do this by:
def click_loginbtn
##driver.button(id: 'loginBtn').click
return ProjectList.new(##driver)
end
Has anyone a good idea for this?

Your driver is still active, you just need to access the new window.
To get a list of active windows available:
#browser.windows
You can switch to another window by handle, title, url, index or collection
#browser.window(title: 'My new window').use
#browser.windows.first.use

Related

Backand- Sign in error with facebook and google

Im developing an app with ionic framework and im using Backand as BaaS, im using the sign in with social accounts service that provides me, but when im trying to sign in with facebook, return this error.
The user is not signed up to 'name-of-my-app'.(signing in with facebook).
And when im trying to sign in with google, return this error:
Object reference is not set to an instance of an object.
Also im create my own apps in facebook and google and i set the AppId and AppSecret to Backand.
I dont know why im receiving this error, actually im ussing almost the same code that the starter's Backand provides.
I have met this kind of error "Object reference is not set to an instance of an object" too, after pressing "Validate & Update" button, after editing database json model several times in the backand control panel. I could save the new model and continue, but that red error was appearing on top right at each save. My hypothesis is that also in your case the issue is related to a bug in the database model editor. I personally got rid of that kind of error by deleting the project (I had no data in it yet) and creating a new one, re-pasting and saving all at once the exact same database model json I created in the previous project.

Parse Signup Problems

So, I wanted to create a new social media app using Swift and Parse. When I go to the Parse site, and click on dashboard, it gives me a login screen. I don't have an account, so I click on the "I don't have a parse account" button. When I click on that, it just takes me back to the home page. I did manage to get the code and frameworks and stuff that I needed from the docs, but that didn't quite work. It gave me this for the initialize code:
let configuration = ParseClientConfiguration {
$0.applicationId = "YOUR_APP_ID"
$0.server = "http://YOUR_PARSE_SERVER:1337/parse"
}
In the tutorial I'm watching, rather than "YOUR_APP_ID" and "http://YOUR_PARSE_SERVER:1337/parse" it just had a bunch of letters and numbers, which I would assume are the app ID and Parse server. My guess is, that I need an account to get those. Would that be correct? And, does anyone know why I can't seem to get an account? Thanks.
Parse.com is shutting down, so that's why you are not allowed to create new accounts on the service. Check the blog post.
They open sourced a nodeJS implementation, which you should definitely check out at link, and here is an example to get you started. You can easily use the deploy buttons to host the server on services like Heroku, AWS, Azure, etc. You can also deploy a server locally, for testing purposes.
Although it's true that Parse is discontinuing early next year, you can still setup a new app if you want to use the service for a shorter term project. Replace your code with the following.
Parse.setApplicationId("YOUR-APP-ID", clientKey: "YOUR-CLIENT-ID")
You can find your App ID and Client ID in your app's settings > security & keys.
EDIT: You definitely need an account for this to work.

Publishing a story using Facebook open graph

I am currently trying to run through the publish open graph story for iOS tutorial on the Facebook website.
https://developers.facebook.com/docs/tutorials/ios-sdk-tutorial/publish-open-graph-story/
I'm getting lost at step 2 - Set up your back end server. I have set up a Heroku account just like it says and I go through the set up tutorial on the Heroku site. It all seems fine. I save the code listed in step 2 in a new file I created called opengraphobject.php (I have no idea if this was the right thing to do?).
After that it says "Once you've uploaded the dynamic object creation code, test a sample object using the Object Debugger. Enter a URL into the debugger, for example:"
https://fbsdkog.herokuapp.com/repeater.php?fb:app_id=233936543368280
&og:type=fb_sample_scrumps:meal
&og:title=Pizza
&og:description="Pizza"
&og:image=https%3A%2F%2Fs-static.ak.fbcdn.net%2Fimages%2Fdevsite%2Fattachment_blank.png
&body=Pizza
I have no idea what I'm supposed to do at this point. My action is called beats and the object is called boss. How do I generate a url like this for my own action?
I can't move onto stop 3 till I move past this because it's very similar.
The page opengraphobject.php should contain the sample code provided in that step.
So when you are done setting it up you point to your url in the debugger to test
https://YOUR.herokuapp.com/opengraphobject.php?fb:app_id=YOUR_APP_ID
&og:type=fb_sample_scrumps:meal
&og:title=Pizza
&og:description="Pizza"
&og:image=https%3A%2F%2Fs-static.ak.fbcdn.net%2Fimages%2Fdevsite%2Fattachment_blank.png
&body=Pizza

Possible to read logged-on user's account name?

I'm developing my first Metro app using XAML. The app is for our company intranet use only. I have these questions -
Is it possible to retrieve the account name (domain\username) of the current logged in user? Do I need to use a WinRT component for this? I looked up Windows.Security.Authentication namespace and only Web and OnlineId are available.
I'm using the WebView control to navigate to a secure URL. If I open this URL in a browser, I do not get any prompts (since my machine is joined to the domain), but if I open the URL in a WebView, I get the username & password prompt. Is there a way to get rid of it?
Update - I was able to solve #2 question by enabling Enterprise Authentication in the Capabilities tab of the Package.appxmanifest file.
For No. 1:
Please use Windows.System.UserProfile.UserInformation class to get all relevant information
GetDisplayNameAsync()
GetDomainNameAsync()
GetPrincipleNameAsync()
e.g. to get the display name
if (UserInformation.NameAccessAllowed)
{
string player = await UserInformation.GetDisplayNameAsync();
}

How to redirect to an external url with Selenium, and come back?

I am working in perl with Selenium RC, server version 2.19.0-b09 and I cannot figure out whether it is even possible to redirect to an external URL and come back to my application. I am trying to test Facebook OAuth in my application, which means I have to go to Facebook and come back to my app.
use Test::WWW::Selenium::Catalyst 'MyApp', -selenium_args => 'injectProxyMode -trustAllSSLCertificates -debug -log /home/me/browserlog.txt -firefoxProfileTemplate /home/me/.mozilla/firefox/SeleniumUser.default/';
my $selenium = Test::WWW::Selenium::Catalyst->start({
browser => '*chrome',
});
The reason I think this is possible at all is because a custom Firefox profile and the -injectProxyMode, *chrome browser and -trustAllSSLCertificates options enable me to post to and see all the redirects in my debug log, but my Remote Control window always disappears after the redirects. I can see the PROXY URL to which Facebook is trying to send me back, e.g., a URL on my own base domain. But it looks like there is no window for it to return to. In multiWindow mode I am left with my application in a Firefox window. In singleWindow mode my tests just end and all the windows close.
I have tried both -singleWindow and -multiWindow mode. I have gotten the list of windows after I make my post to https://www.facebook.com:443/login.php... and before all the redirects. I see a single window that is never available to select_window, and it always disappears on the second iteration if I run get_all_window_names in in a while loop: a window with a name like "_e_0RWG".
So, how could I conceivably do what I am trying to accomplish with Selenium? It seems so near and yet so far.