You guys know how google keeps you signed into different websites? how come whenever I use Selenium/Chrome driver and have it go to a website I'm already signed into, it is like im a fresh user and I have to have Selenium go through the work of signing in, which in some cases I cant because some websites block me from signing in with selenium because they know I'm using a bot.
Google keeps you signed into different websites through your Default profile.
Where as Selenium driven ChromeDriver initiated google-chrome Browsing Context is opened everytime with a newly crated temporary profile.
Related
I'm trying to incorporate scraping data from the AWS management console into an automation script, and for some reason my company's AWS is behind a Microsoft multi-factor authentication system. This isn't an issue when going to the console link manually, as the browser remembers that in the past I've already gone through the MFA process and I am directed right to the console. When navigating to the same link in Selenium I am instead brought to the MFA page asking my permission to text/call my phone.
I learned that this could be solved by setting Chrome Profile in the Webdriver options.
options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=/Users/myuser/Library/Application Support/Google/Chrome/")
Even after setting this I am still redirected to the MFA page every time. Am I going about this the wrong way? Is there an easy way to check if the Chrome Profile is actually working as expected?
You need to use an actual user data dir not just the folder where the general chrome data is stored.
For the default chrome profile the name would be:
"/Users/myuser/Library/Application Support/Google/Chrome/User Data/Default"
//Add argument and provide path to userdata
Remember to change username to your username.
Option.AddArgument("user-data-dir=c:\Users\~username~\AppData\Local\Google\Chrome\Userdata");
//Add whatever profile number that corresponds to session you want to open
Option.AddArgument("--profile-directory-Profile-10");
*Find profile by using chrome://version flag in session you want to use. The flag will tell you profile number.
I use the following code to open a Chrome window using Selenium:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.youtube.com/")
However, whenever I enter the site, I am logged out. On other sites, I can manually do so, but Google deems it unsafe to log in with Selenium.
I know that Selenium is a test browser, but is it possible to stay logged in with Selenium so that I can access my user data; or is that not the purpose of Selenium, and calling the Chrome subprocess the way to go?
To start with Selenium isn't a browser as such but a bunch of libraries which helps in simulating Browsing Context.
From the question it's not that clear why you are logged out once you login in to the site. But definitely once you are logged in using Selenium driven ChromeDriver initiated google-chrome Browsing Context you must remain logged in and should be able to access your user data.
I want to fill some field of a webpage and then send a request to it
but this website has a very powerful login page to avoid sending requests for login from a robot
so I can't log in with selenium but after login, I can use selenium and I can send requests, on the other hand, I write this program for an app so I can't open a web driver and then work on it
I need to work on a tab that exists
I want to program work on a session that a human opened
From what I understand from your question is that you want to open an existing browser that is launched by a human.
There are multiple ways to achieve this and as mentioned by Devansh in the comment, You can use the session ID to get the already launched browser and execute your test script on it.
However, there is another way that might be able to solve your issue of executing scripts on already open connection or logged in user.
You can use the profiles of browsers for this scenario, User profiles in a browser are like user accounts on a computer.
You can use the answer to this question to create and use profiles in your script:
Opening an existing tab/logged in user using Chrome Webdriver
Now You can manually log in the required account for the website on the above profile you are struggling to log in and then launch the scripts.
I'm trying to automate sign in into gmail and I get to see this error.
I think this must be because the website is able to detect the automation and blocking it. Can you all please tell me how to overcome this?
I don't see this issue with my personal account but this happens only with a common account.
In you account profile, in Security options, try setting this option:
This issue was because of the selenium chrome profile.
I have created a new chrome profile and logged into it with the email id with which I was facing this issue. Then Turn on sync.
With this chrome profile in place I can skip the login steps and directly do the main process.
Use: Chrome Options to add newly created chrome profile as an argument.
Hope this helps people who are facing similar challenge.
I faced this issue.
I have created dummy gmail account and now my selenium script is working fine for the same and able to login successfully.
it's not working for my personal gmail account.
Thanks !!
I am trying to automate the connection to a secure site that requires certificate authentication, in Python. This is from Windows, and does not have to be headless. My organisation does not play well with Firefox, so I have chosen to do this in Chrome. The certificate is a .pfx
I have come across older posts saying it cant be done at all with Chromedriver but a potential workaround would be to create a profile and import the certificate to that profile. When running the code, I reference the profile.
My code so far:
from selenium import webdriver
import time
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument('user-data-
dir=C:\\Users\\User\\AppData\\Local\\Google\\Chrome\\User Data\\')
driver = webdriver.Chrome(executable_path='C:\\Users\\User\\WinPython-
64bit-3.5.4.0Qt5\\python-
3.5.4.amd64\\chromedriver.exe',chrome_options=options)
time.sleep(3)
driver.get('https://www.securesite.com')
This code results in a "This site can’t be reached" response. When trying it manually, a prompt will popup to choose confirm the certificate to use and I am able to proceed to the site successfully.
When viewing certmgr.mmc I can see the certificate is imported under Personal as well as I have imported it to Trusted Root CA. From Chrome though when I view certificates, I find it only under Personal.
I am not sure what I am doing wrong here, and I am hoping that during recent times - a solution has been found so someone would be able to advise me.
Thank you