How to keep log in credentials on Internet Explorer on Selenium - python

I'm currently working on a script that opens a URL and then click on buttons on a form in Internet Explorer specifically and repeat every x minutes. The problem I'm facing is that the website requires log-in credentials and it is not quite secure to hard code credentials inside the script.
The intention so far is to have Selenium open open a new tab inside an existing instance of IE that is already logged in. This would then allow the script to perform each time without having to enter credentials each time it runs.
How would I go about either doing the above and/or performing the same outcome (having selenium work on a IE instance with the log in credentials)

Related

Selenium - Login to google ads with cookies and account suspicious activity

I have been using selenium to scrape data from Google Ads Account, I log-in manually using my profile data first and then save the cookies to be used to later to automatically login and then run the scraping task, some times the script runs on VM, not the machine the cookies was created.
Everything was going fine but sometimes, approximately every 10 days, I get an email that there's suspicious activity in my account and google sign me out automatically and I have to change my google account password recreate the cookies manually.
I'm thinking that the problem comes from the fact that the cookies was created on a machine and being used on other but not sure.
I'm thinking of creating the cookies on the VM and only using it there, but not sure if that would work?!
That might be because google detects, that your using the same cookie in a browser with different useragent & device-metrics.
To bypass that, you could try using Selenium-Profiles and start it, using a profile previously exported from your local browser.

Setting Chrome profile in Selenium doesn't bypass Microsoft MFA

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.

How to make chromedriver open chrome open as a new user in python programatically

I have a use case for my client where we want to perform test automation using Selenium in python and behave framework.
Now the client website is actually behind an Azure AD Authentication. So for example I am logged into a machine as user ABC, and I try to access the website it will log me in with that user. But if I want to login with another user id for ex: XYZ this will still login to ABC. To avoid this from happening we need to right click on chrome and say start chrome as another user. This will then give a popup for username and password with an attached domain.
So I want to ask is there any way we can do this programmatically using selenium web driver python code. I.e. is there any way to start chrome as another user programatically where I can specify the domain,username and password.

how to work on a exist session in selenium with python?

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.

How to make Selenium Chrome Driver to open on a new tab in a pre existing window

Hello I am currently working on a selenium script that goes onto a shopping website that auto carts and checkouts an Item for you It has a captcha In it during the end and almost never pops up if you are logged into a google account.
My program always opens up in a new chrome page and I always get the captcha. I just want to know if there is a way make the script open In a new tab on my pre-existing page (where I am signed into my google account)
(also if anyone knows how to make a captcha harvester/bypass I would appreciate on how to fit it into my script).
URL = https://etc..
here is some part of my scipt:
driver = webdriver.Chrome(executable_path='/Users/(username)/Desktop/chromedriver')
driver.get(URL)
(also not as important I want to turn this script into a shareable application for computers where I can turn my "raw_input" into text boxes where people can simply type in the stuff and it would save and run the program.) ( I use stuff like driver.find_element_by(blah).click and .send_keys

Categories

Resources