I am trying to use Selenium's Chromedriver to log in to a website which has cookies enabled. I got a message from the server that the browser has cookies disabled. How can I enable cookies in Chromedriver?
ChromeDriver has cookie be enabled by default.
Please try the following steps:
Use FirefoxDriver/IEDriver, see what the site says.
Manually open a Chrome browser, see what the site says.
Try open whatismybrowser.com with ChromeDriver opened browser, see what it tells you.
If your site says cookie not enabled for FirefoxDriver/IEDriver/Manually opened Chrome, and whatismybrowser.com says your ChromeDriver opened browser has cookie enabled, then clearly something is wrong with your site, please try debug your site.
What I did to use an instance of Chrome with Selenium where I was logged in was to run the following Python code, which opens a new instance of Chrome.
If you already had Chrome open on your computer this will be a different instance of Chrome and you may see the Chrome app open in two different instances. With this new instance open I logged in to my account manually, then quit the new Chrome instance and ran the code again and then I was logged in.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
url = "urlToWebsiteToLogin"
chrome_options = Options()
chrome_options.add_argument("user-data-dir=/Users/username/Library/Application Support/Google/Chrome/Default") #path for MacOS
chrome_options.add_experimental_option("detach", True) #prevent window from closing
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get(url)
Remember to quit the Chrome instance before running the code again or you will get the following error:
invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir
Related
I am currently using window.assign(bundlename://linkname) to deeplink a user into the app if it’s installed on their device but I keep getting Safari cannot open page because the address is invalid
I also tried to use window.location.assign = bundlename://linkname but that does not work either
Thanks for the detailed comments - I am able to open with document.location
See this sandbox, replace with an app scheme if you do not have Doordash installed - https://codesandbox.io/s/cranky-lewin-ydbp5?file=/pages/index.js
Summary
Environment: Windows Server 2016, IIS 10, ASP.NET webforms site, Wildcard SSL/TLS Certificate, IIS URL Rewrite 2.1 (MS supported download)
Goal: a) Determine and resolve the root cause(s) of the issue, b) [preferred] Get the two failing features working without users having to change settings on their browser, c) get the two failing features working, period, without first-time-processing issues on ubiquitous browsers (Chrome, FF, Edge, IE, Safari, Opera).
Issue Summary: Two of the site features i.e. downloading files and displaying SSRS reports fail with a first-time-processing error or fail entirely, depending upon the browser, with the SSL certificate bound to the site. Subsequent attempts to execute these features within the same browser window succeed in most cases. Various browsers fail in different ways and some don't fail at all depending upon the browser in question. Please bear with me as I try to provide details below.
NOTE: Both features work fine without the SSL certificate in the mix.
I have scoured the Internet for a solution to no avail and would be very grateful for any assistance on this.
Details
I have a client with an ASP.NET Webforms site containing file download and SSRS report display features. Users must be logged in to access these features. Sadly, the original developers implemented a rudimentary, homegrown approach for authenticating users i.e. it's not a "formal" authentication framework but, rather just a simple comparison of the provided username/password pair to the values stored in the database ... no formal authentication tokens are set to my knowledge ... could this be part of the issue?
Both of the aforementioned features have been working flawlessly for years using all current, major browsers. My client recently purchased a wildcard SSL/TLS certificate which I installed on the production IIS instance and configured the appropriate site bindings. In case this matters, the site is also using URL Rewrite with a basic rule in the web.config to modify all HTTP protocol requests to the HTTPS protocol.
All aspects of the site work fine with the SSL certificate in place except file downloading and SSRS report displaying. Current versions of Chrome and Firefox [Windows], and Mac browsers (I don't have first-hand access to a Mac environment) are exhibiting errant behavior. IE 11 (go figure) appears to be the only browser with no issues whatsoever. I have not tested Edge as I don't have access to that browser version.
File Downloading
The site has a feature that allows logged in users to download files from the site.
Chrome
Chrome displays a first-time-processing error "Failed - Network error" shown in the download status bar at the bottom of the browser. Clicking the chevron in the error message and choosing the "Resume" option from the context menu completes the download but, any attempt to open (double-click) the zip archive from its actual folder location results in the following error message: "Windows cannot open the folder. The Compressed (zipped) Folder '{path}' is invalid." Analyzing the zip file in a hex editor reveals that it contains the web page source code and not the intended file download. Repeating the file download operation in the same browser window works fine (culminating in a successfully downloaded, valid zip archive of files) and all subsequent file download attempts also succeed with no further issues for the remainder of the life of that browser instance. If the user closes their browser (all Chrome instances must be closed) and then re-opens Chrome navigating to the site, the browser, again exhibits the first-time-processing error and then works fine from then on for the remainder of the life of that browser window.
NOTE: All instances of the Chrome browser must be closed to reproduce the issue a second time. If the user leaves even one Chrome instance open on their computer and then navigates to the site using a new browser window and retries the file download, there are no issues. Perhaps Chrome is caching some kind of an authentication token? I am intentionally shying away from using the term "session" as the behavior does not appear to be session related. Opening a new tab within Chrome (after experiencing the aforementioned first-time-processing behavior) and navigating to the site (which culminates in a new session) does not exhibit the issue.
Firefox
Firefox displays a "Secure Connection Failed" error message when trying to download files from the site. All subsequent attempts continue to fail. This differs from Chrome's first-time-processing only behavior. Modifying the Firefox advanced preference "network.http.spdy.enabled.http2" from true (the default) to false permanently resolves the issue.
IE 11
IE 11 does not fail at all. No browser settings were altered from the default installation of IE 11.
Mac Browsers
Mac users report that file download attempts appear to succeed but attempts to open the zip archive culminate in the Mac environment thinking that the zip archive is password protected. NOTE: There is no explicit assigning of a password to the zip archive in the code that processes the download request. No users in Windows environments report this behavior.
SSRS Report Display
The site has a feature that allows logged in users to display a PDF document created at runtime from SSRS. The PDF displays directly in the browser window (as opposed to immediately initiating a download operation).
Chrome
Chrome displays a similar first-time-processing error when the user attempts to display an SSRS report. The browser displays the following error message: "Error Failed to load PDF document." The error message has a "Reload" button which culminates in the report displaying successfully. All subsequent attempts to display reports in the same browser window succeed with no further issues. The first-time-processing behavior is, again, experienced when the user closes and re-opens Chrome to the site, and retries the report display.
NOTE: It is interesting that in Chrome with either feature (file downloading or SSRS report display), once the user has experienced the first-time-processing issue with either feature, then the other feature works fine with no issues for the life of that browser instance. Example: User opens new Chrome instance, navigates to site, and attempts to download files. The file download will fail the first time. Immediately attempting to display a report succeeds ... and vice versa.
Firefox
Firefox displays the same "Secure Connection Failed" error message as was the case with the file downloading feature. Modifying the same Firefox advanced preference "network.http.spdy.enabled.http2" from true (the default) to false permanently resolves the issue.
IE 11
IE 11 does not fail at all. No browser settings were altered from the default installation of IE 11.
I am using flutter web and firebase authentication to build a web app. For that
1. Created Firebase app with Google signin as one of the sign in methods.
2. Added the dependencies as given in https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_auth/firebase_auth/example
and https://dart-pub.mirrors.sjtug.sjtu.edu.cn/packages/firebase_auth_web.
When I try to login, the Google sign-in window appears. Once I enter the email address and press enter, it gives the following error.
"Couldn't sign you in This browser or app may not be secure. Try using
a different browser. If you’re already using a supported browser, you
can refresh your screen and try again to sign in."
I used Chrome browser.
What should I do to make my app more secure ? For android, we had the option of using SHA keys to encrypt the connection. Do we need to do something similar for web ?
Incomplete answer:
This problem isn't specific to flutter. It happens whenever you try to sign in to Google in a Chrome instance that has debugging turned on. In other words, if you, your automation software, or IDE starts up chrome with a command like chrome.exe --remote-debugging-port=9222
If running Chrome normally (out of debug mode) is not an option, then try https://support.google.com/accounts/thread/22873505?msgid=24501976 or if you are using Electron then try https://support.google.com/accounts/thread/22873505?msgid=24503570 but I, personally, haven't been able to make these work for me, yet.
Please upvote the question at https://support.google.com/accounts/thread/25209002 if you want a solution to this problem that actually works.
The issue was with the chrome developer version Flutter use to launch as a device. If we open the same URL (localhost:portnumber) in the normal chrome, it will work without any issue.
The following worked for me:
Go into your google account
select Manage Account
Security
Less secure app access (need to scroll down a little bit)
set to off
Then I was able to login in and debug in IntelliJ
(for me, for some reason, I had to create a new google account, couldn't get it working with my existing account but it worked with my new account)
You can use user agent switch to switch another browser (for example opera).
https://chrome.google.com/webstore/detail/user-agent-switcher-for-c/djflhoibgkdhkhhcedjiklpkjnoahfmg
They try login. Once you successfully logged in you can remove or disable the extension.
I had the same problem with Firefox. The only way I could fix it was to create a new profile. So you could try to run Firefox with -p switch and create a new profile.
firefox -ProfileManager
firefox.exe -p
Update: check the firefox config (address field: about:config)
be sure marionette.enabled is false
For Test Automation Users-:I saw many testers are facing this issue for sign in using Google but I think below my idea will save their time.
Best Work Around is as below-:
Open automated Chrome browser as shown below
Sign up with new details which you want to use.
Now after successfully completion of sign up.
Then use that email and password for signing into gmail using Selenium or any other test automation tool
Using MobaXTerm on RedHat, I am able to launch Firefox from my user profile and access browser GUI. However if I sudo to root and try to launch firefox I get an error:
X11 connection rejected because of wrong authentication.
I want to access CUPS in the browser with root access so that I can administer printers from GUI (not trying to browse as root!). I am aware that all of the administration can be done from command line, but sometimes the GUI is just easier.
How can I resolve this error so that I may launch firefox as root?
Under my user profile where firefox is working, run:
xauth list
The output will be something like:
servername/unix:11 MIT-MAGIC-COOKIE-1 256d99dc3f0f7acdf90190a2710d7042
servername/unix:11 MIT-MAGIC-COOKIE-2 61f888d3342b65f4f05f02fcb708f3d8
servername/unix:11 MIT-MAGIC-COOKIE-3 656d49dc3f0f7acdf96190a2710d7042
Copy the list of these entries.
Then sudo to root and run xauth list again. You will find a different list of cookies.
To repair the trouble, add each of the cookie under my user profile to root's profile via xauth add command:
xauth add servername/unix:11 MIT-MAGIC-COOKIE-1 256d99dc3f0f7acdf90190a2710d7042
As far as I know each cookie needs to be added one at a time, but someone jump in if they know of a bulk method.
After adding the cookies to root profile, Firefox can be launched from root.
Thanks to Byron for the help on this.
I am using Selenium Webdriver for Automation. Lately I have a need where I open a webpage, install a plugin(in the backend) and click a button. The button detects the installed plugin and lets me continue.
I can see this working in the normal firefox window. But somehow the WebDriver initiated firefox does not allow the same. The plugin is instantiated in the webpage and the button gets enabled.
I could install the plugin and see it in Add Ons page but the button is not getting enabled.
Is there a way I can force the webdriver to reload all the plugins or is there any security issue due to which webdriver is preventing the plug in from being instantiated?
Thanks in advance
If you want to use Add-on's mean you have to create a profile for Firefox and include add on's in that profile that is launched by the web driver applications. This will allow you to have access to the `Web Element' through add-on's. I am not sure how it will react. I didn't tried not yet. But this the way to use plug-in to the launched browser.
File file = new File("firebug-1.8.1.xpi");
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.addExtension(file);
firefoxProfile.setPreference("extensions.firebug.currentVersion", "1.8.1"); // Avoid tartup screen
WebDriver driver = new FirefoxDriver(firefoxProfile);
Reference from - http://code.google.com/p/selenium/wiki/FirefoxDriver