Summary
I have a Xamarin application which creates a GoogleApiClient and calls EnableAutoManage. When my app runs, I am asked which user account to use, and then the app hangs on a blank popup page with a Google-themed spinner. Why is this happening?
Details
I have been following this video which shows how to set up an application's to read Google Fit data. Notice the timestamp - this is where the code is presented.
https://youtu.be/j_zsNxMI6jI?t=2172
I have followed the examples here, and have narrowed the problem to this piece of code:
// In my MainActivity's OnCreate:
try
{
int defaultClientId = 0;
googleApiClient = new GoogleApiClient.Builder(this)
.AddApi(FitnessClass.HISTORY_API)
.AddApi(FitnessClass.RECORDING_API)
.AddScope(FitnessClass.ScopeActivityRead)
.EnableAutoManage(this, defaultClientId,
result =>
{
int m = 3; // Breakpoint here is never hit
})
.Build();
}
catch (Exception e)
{
int m = 3; // Breakpoint here is never hit either
}
If I run my app (tried on both emulator and physical hardware), I am first asked which account to use.
After selecting the account, another popup appears with a Google-themed (changing between red, yellow, green, and blue) spinner at the top. The popup stays on screen and the spinner animates indefinitely.
As noted in the code above, no exceptions are raised, and no result is returned in the EnableAutoManage delegate. Why is this happening?
Update 1
If I remove the following line, the app no longer shows a spinner indefinitely:
.AddScope(FitnessClass.ScopeActivityRead)
The addition of this line of code seems to be the cause of the popup with the spinner.
Update 2
I thought I'd try the "new" approach of using GoogleApi rather than GoogleApiClient as explained here:
https://android-developers.googleblog.com/2017/11/moving-past-googleapiclient_21.html
Unfortunately, there seem to be no Xamarin bindings for this yet:
Xamarin Android: Cannot resolve GoogleSignIn and GoogleSignInClient
The reason this happened is because my google account hadn't yet been added as a test user. One might expect that Google would provide some kind of useful feedback through a popup, but instead it provided an empty page.
To solve this problem:
Go to https://console.cloud.google.com/apis/dashboard
Click on OAuth consent screen
Scroll down to the Test Users section
Enter the email addresses of the test users you would like to use testing your app (such as your own personal gmail)
Now the app should properly display a confirmation page.
Related
This is how the Auth0 login screen appears when I open it from a C# WPF app:
Auth0 login window
The top portion can't be seen. There are no scrollbars and the window cannot be resized. Only the full screen option allows the user to see the entire login form.
Here's the code I'm using to open it:
try
{
var auth0 = new Auth0Client(
Properties.Settings.Default.auth0Domain,
Properties.Settings.Default.auth0ClientID);
var handle = new WindowInteropHelper(this).Handle;
var windowWrapper = new WindowWrapper(handle);
var user = await auth0.LoginAsync(owner: windowWrapper,
withRefreshToken: true, device: "DeviceName");
}
catch (Exception e)
{
Utilities.AppendLog("User login exception: " + e.Message);
}
I'd like to resize the window so the user can see the entire login form. What do I need to do?
Misunderstood.
That entire login screen is done by Auth0Client. The window handle you are passing in is just the parent for that popped up login window.
Here's the source code to Auth0Client:
https://github.com/auth0/Auth0.WinformsWPF/tree/master/src/Auth0.Windows
Taking a look at their login screen...it is a Windows Forms "form" which appears to be of a fixed size. Within that "area" they are using a WebBrowser control...which then is using an Auth0 "domain" url to do the actual logging in.
Here's what it looks like for me, when using their sample applications to do a login - it looks different in its layout to you.
Did you change a setting in your Auth0 account to show the login options in a different way (i.e. with labels?) - I'm not familiar enough with Auth0 to know where that option is. Perhaps it is one of their "extensions" you are using?
It's possible that their "web page" design for a login using icon+name style list...doesn't get laid out properly when there are a number of "connection" types....and limited "height" in the "browser".
What you could do is either:
"tweak" that BrowserAuthenticationForm so it has a bigger vertical size, so there is plenty of room to fit the list of login types into
or
if such an option exists, stick to the "icon only" style of list rather than "icon+name"
Also make sure you are using the latest version of Auth0....though I'd think you probably are already...and it probably won't make a difference to the presentation.
Lastly, here's what it looks like if you just use a browser (e.g. Chrome), and size it so that the "client" area height is about 565 pixels...which is the same as the WebBrowser control height in BrowserAuthenticationForm - notice the "title" being clipped (note I only have 4 log in provider options...compared to 5 in yours).
And if you make the browser a bit taller...then you can see it all.
Unfortunately, the way they've designed that popup HTML form doesn't work in limited height situations, and what's more "scrolling" has no effect if part of the "login screen" is being clipped.
(the WebBrowser already has "scrollbars" enabled...so that's not stopping any scrolling).
You mentioned that one of your team modified the login screen and I believe that is defined in the "Hosted Pages" section of the Auth0 admin site....maybe you can tweak that a bit more.
I have a problem with blocking iframes in the webbrowser control. Currently I am using this code:
foreach (HtmlElement x in ((WebBrowser)sender).Document.GetElementsByTagName("iframe"))
{
MessageBox.Show("iframe!"); //DEBUG
x.OuterHtml = #"<iframe src=""about:blank"" frameborder=""0"" style=""display:none;""></iframe>";
// x.OuterHtml = String.Empty; //gives the same result
}
It works but when navigating to www.popuptest.com , the application just freezes completely because of this code. It shows 2 "iframe!" message boxes and freezes after closing the second one.
I have found the 2 iframes in the source code of webpage (in the advertisements shown on that website). This is the code that is causing it to freeze:
(a=document.createElement("IFRAME"),a.frameBorder=0,a.style.height=0,a.style.width=0,a.style.position="absolute",t=a,document.body&&(document.body.appendChild(a),a=t))&&(a=a.contentWindow)&&(r="1",a.document.open(),a.document.write("<!doctype html><html><head></head><body></body></html>"),a.document.close(),k(a.document))
I guess it is because of the frame being created in a different way? I have tested it both on win7/IE10 and winXP/IE6 and the result is the same. On winXP, however, it crashes and opens the debugger instead of freezing and that is how I got the faulty code.
Is there a better/safer method of removing the content of iframes?
I would try disabling frames using Download Control (DLCTL_NO_FRAMEDOWNLOAD). Here's how it can possibly be done, although I haven't tried that myself. Let us know if that works for blocking frames or not.
I'm developing a Windows Phone application and I have three screens:
Main screen
Login selection screen.
Sign in screen.
When user has signed in and push "sign in" button I want to come back from screen 3 to screen 1.
Now I come back to screen 2 and immediately to first one. I don't want to show 2 screen.
Is it possible to do this?
Try this
Assume your pages are named as FirstPage.xaml, SecondPage.xaml, ThirdPage.xaml
//Check for the first page and remove the remaining back stack in your ThirdPage.xaml
while(!NavigationService.BackStack.First().Source.OriginalString.Contains("FirstPage"))
{
NavigationService.RemoveBackEntry();
}
NavigationService.GoBack();
Somewhere in page 3 add
NavigationService.RemoveBackEntry();
This will remove page 2 from the back stack. Now when the user hits the back key, he'll navigate directly backwards to page 1.
But as Amal Dev noted, Microsoft wants you to let the user navigate to the previous page. This rule doesn't seem to be enforced too much, it's probably meant as "never ever confuse the user". If you confuse the certificating tester, your app will fail certification.
You can use the NavigationService.Navigate method for this.
NavigationService.Navigate(new Uri( string.Format("/your page name.xaml?val={0}", ValueTextBox.Text), UriKind.Relative));
Please refer the link given below.
Simple Navigation In Windows Phone 7
Assume that there is a web site which includes 3 different pages.
I want to show a text one of the pages randomly, with is formatted with css.
For instance the pages are below:
hello-world.aspx
hi-sun.aspx
good-night-moon.aspx
* When John enters to the site, the text will appear on hi-sun.aspx,
* When Elmander enters to the site, the text will appear on hello-world.aspx
And when one enters the page which includes a special text, even if come again, it shouldn't appear.
Psedue Code:
if(Session["first"] == "1")
{
//show the text in a random page
}
else
{
//text.visible = false
}
in the if block
how can I supply the text in a random page. (it shouldn't appear in every page, should appear only one page)
How can I do? Are there any suggestions?
Thank you.
I don't fully understand what you want to do, but I think it's something like this:
You have a couple of different sites (3), and you have a text (welcome or something) you only want to show once. But after typing in your url the user should see one of the sites randomly.
For the first (if you don't want the user to log in) you can either save some flag in the Session object or create a cookie for the user (saying he has seen the text) and check this every time you want to show it.
The session will on the server but will be lost so the user might see the same message later again if he revisits your site. But while staying he will see it only once.
The second is on the client. If he accepts the cookie he will never see the message again if not he might see it everytime because you cannot know. Maybe you want some combination of these both.
For the second you will have to send a redirect if you don't want to get fancy with a deep dive into System.Web.
In the case above you can just do:
if(Session["first"] == null)
{
Session["first"] = true;
//show the text in a random page
}
else
{
text.Visible = false
}
but note that the session will not stay forever for the current user.
I am testing a web app where i delete an item from a list. Upon clicking on delete, the app asks for confirmation. Selenium IDE detects it as a confirmation box. When I run the code thro' the RC (C#), it even catches the confirmation-box, executes the click of delete button on that confirmation box, but, the confirmation box is never visible on the screen. Further, it only clicks on the delete button; the item doesn't get deleted. I tried it manually, works fine.
Please help, I'm new to Selenium and tried to find the answers at multiple forums without any success.
Here's the code:
string confirmation;
for (int second = 0;; second++) {
if (second >= 60) Assert.Fail("timeout");
try
{
confirmation=selenium.GetConfirmation();
if ((confirmation == " Delete confirmation message")) break;
}
catch (Exception e)
{
PrintLog("Error while waiting for confirmation. Error: "+e.Message);
}
Thread.Sleep(1000);
}
try
{
Assert.IsTrue(confirmation == "Delete confirmation message");
}
catch (AssertionException e)
{
PrintLog(e.Message);
}
selenium.FireEvent("//a[#id='btnOkConfirm']","click");
After the last statement, the selected item must get deleted and page should refresh, but, nothing happens. All I can see is "Javascript:;" written in the status bar of the firefox window. I guess its problematic to get javascript hrefs working in selenium-rc.
Thanks,
Vamyip
There are a number of commands to deal with JavaScript confirmations. Selenium will by default choose 'OK' at a confirmation, unless you send the chooseCancelOnNextConfirmation command. In order to consume the confirmation you will need to use the getConfirmation command.
Selenium reference for above commands:
http://release.seleniumhq.org/selenium-core/1.0/reference.html#storeConfirmation
http://release.seleniumhq.org/selenium-core/1.0/reference.html#chooseCancelOnNextConfirmation
http://release.seleniumhq.org/selenium-core/1.0/reference.html#chooseOkOnNextConfirmation
Additionally, if your click command is not showing the JavaScript confirmation you might find that the appropriate event is not being fired. You could try using the mouseDown and mouseUpcommands, or the fireEvent command.
Lately, I've discovered that this behavior is occurring due to the architecture of selenium(more precisely, its javascript based core). when I do the test manually, keeping the selenium IDE open, this behavior is replicated. So, I think there's no immediate solution to this problem right now. Will post here if I find a workaround.
Thanks to Dave for replying.
Update: The development team informed me that a javascript function is not being called with selenium IDE running alongside. This indeed is a problem with Selenium's Javascript core.
Thanks to everybody who took time to respond to this question.
Regards,
Vamyip