Can Selenium Command Line Runner run .side files using a local, authenticated Chrome profile? - selenium-chromedriver

For lord knows what reason, I'm trying to use Selenium Command Line Runner to run some tests inside a particular Selenium IDE .side file that crawl the UI of a logged-in G Suite account. This is not a problem in the IDE--I can log into the G Suite account, install the Selenium IDE extension, open my .side file, and run all its tests--the browsers are all authenticated. Is there any way for me to launch that .side file from the command line instead?
The first thing I thought to try was to see if the command line runner could run the tests inside a particular .side file using a particular local chrome profile, one that was already authenticated. However:
selenium-side-runner -c "browserName='chrome' chromeOptions.args=[profile-directory='Profile 2', user-data-dir='/Users/username/Library/Application Support/Google/Chrome/']" Calendar\ Settings.side
merely launches the file in the typical default, unauthenticated Chrome profile. Because my test is configured to open a URL that assumes one has already authenticated, I'm brought to Google's authentication screen.
I'd like either to a) have the command line runner run the .side file in an already-authenticated chrome profile, or b) have the .side file's suite of tests begin with an authentication flow, then have the remaining tests in the suite run in the authenticated chrome profile. Is there a way to do either?

Related

How to run multiple chrome profiles in different remote debuging ports in ubuntu?

I have 2 chrome profiles. My aim is to control these 2 windows using puppeteer. So first, I have to open these profile windows via command line, specifying the debugging ports.
command 1: google-chrome --remote-debugging-port=9222 --profile-directory="Default"
command 2: google-chrome --remote-debugging-port=9223 --profile-directory="Profile 1"
When 1st command is executed, it opens a chrome window with the profile I mentioned. And I also get a WS URL for that browser. So I can use that in puppeteer.
Problem is while running second command. It also opens the profile, but no URL. It says "Opening in existing browser session".
I want to open more profiles and control them with puppeteer. Please help.

Clasp Could not read API credentials. Are you logged in globally?

I'm logging in with clasp login --creds <file> which produces a local .clasprc.json file.
It says that I am logged in, but when I run another command I get:
Could not read API credentials. Are you logged in globally?
Any thoughts on why its not looking at my local clasprc file first?
Currently using version clasp v. 2.2.0
I ran into the same problem on Windows 10 and found that you need to login both globally and locally to use clasp run. There should be a .clasprc.json file in both your project folder and user folder.
I think I have finally found the solution for the same problem
Follow along with the comments from this github issue
Add the "oauthScopes" field to your local code and push it to your app
If you can't push, then copy-paste it to manifest file in the browser
Then you have to publish the app, and there were few things I've done, not sure which one helped. In the app in browser:
add the app version in File->Manage Versions
Publish -> Deploy as API executable
try to login with clasp and creds.json file
try to run something clasp run testRun
it may show the error that you're missing some oauth permissions, but it will list which ones, and you can add them
In my case, one weird thing that also helped was to enable some Google API
so in the app in browser: Resources -> Advanced Google Services -> enable some API
then try to do clasp run
if it works, you can disable the API that you have enabled previously.
Hope that helps

enabled/disabled google chrome extension with command line

There is a way to enable/disable google chrome extension with a command line ?
I would like enabled un extension already installed by terminal.
Launch Chrome with extension parameter may help you.
Example:
launch chrome with cmd
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -no-first-run --load-extension="extension path"
Here's an architecture example for what wOxxOm proposed in comments:
An extension can enable/disable other extensions with chrome.management API and "management" permission.
An extension can spawn a companion daemon process that communicates with the rest of OS using Native Messaging's chrome.runtime.connectNative().
Said daemon can create a named pipe that you can write to from the command line, and pass whatever commands are sent to the pipe to the extension using the Native Messaging protocol.
Note that Chrome cannot be contacted from "outside" directly: it must spawn a process on its own, and then you can communicate with the process.
Alternatively (if you don't want to use the Native Messaging protocol, or want the daemon to exist independent of Chrome), your daemon can open a local WebSockets server and your extension can communicate through that. However, it would be possible to impersonate your extension in that case.

How to create a Chrome profile programmatically?

Development, testing, staging environments are controlled via different proxy servers in my setup. I want to script creation of multiple Chrome profiles (sometimes called "user" or "person") and connect to a different proxy server for each of them. Finally I want to share this script with colleagues so that they have access to the exactly same setup.
The latter can be done via scripted installation of extensions such as Falcon Proxy or Proxy Helper to the Chrome profile. I would like to know how to script creation of the different profiles.
A profile is a folder inside ~/.config/google-chrome (Linux, ~/Library/Application Support/Google/Chrome (Mac OS X) and %USERPROFILE%\AppData\Local\Google\Chrome\User Data (Windows). But how to create and initialize one? Where do I register the new profile?
Creating a user
The following example applies to Windows, but the basic procedure should be the same.
First, change to the UserData folder in your Chrome installation:
cd "%APPDATA%\..\Local\Google\Chrome\User Data"
This method will copy the current user as a template for the new user. If the new user should be blank, you need to delete (CTRL + SHIFT + DEL the current browser data).
Now create a new user:
mkdir NewUser && copy Default NewUser
Change your directory to the chrome installation:
cd "C:\Program Files (x86)\Google\Chrome\Application"
Factory-Reset all user parameters:
chrome.exe --user-data-dir="..\User Data\NewUser" -first-run
where --user-data-dir is the path (full or relative) to the previously created NewUser directory.
Running as NewUser
To run chrome again using this profile, simply run chrome without the -first-run flag.
From this documentation, I finally found a way to create a user/person, rather than a separate profile. The difference is especially important in Mac OS X since different profiles can be opened concurrently using the same Chrome process.
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --profile-directory="StagingEnv" --first-run
The only unfortunate fact is that this new person doesn't inherit the name from the profile directory. Instead, it is always called Person X where X is an increment number.
I need to go to the Local State file to change it.
grep -o '"StagingEnv":{[^}]*}' ~/Library/Application\ Support/Google/Chrome/Local\ State
"StagingEnv":{"active_time":1437709453.172762,"avatar_icon":"chrome://theme/IDR_PROFILE_AVATAR_6","background_apps":false,"is_ephemeral":false,"is_omitted_from_profile_list":false,"is_using_default_avatar":true,"is_using_default_name":true,"managed_user_id":"","name":"<b>Person 3</b>","user_name":""}
This file is overridden when Chrome quits, so I need to kill Chrome, change the file and run Chrome again.
I think the easiest way to create multiple chrome profile is
On your computer, open Chrome.
At the top right, click Profile.
Click Manage people.
Click Add person.
Choose a name and a photo/picture.
Select Create a short cut on the desktop.
Click Save. A new window will open and ask you to turn on sync which is
optional.
By this, each chrome profile will be created and you can check on C:\Users\youname\AppData\Local\Google\Chrome\User Data.

Jenkins won't execute correctly a command from a .bat

I have set up Jenkins so that it builds my project, runs some tests and then creates an HTML page containing a report.
I made a .bat file to open the html report in my browser. There is just one line in that .bat file :
"E:\user\Visual Studio 2010\JenkinsWorkspace\JobTest\index.html"
When I run that .bat in a prompt myself, the page index.html is open (so it works).
But the problem is that when I set up a Jenkins' job to run that .bat, nothing happens.
The job gets stuck after calling the .bat and never finishes.
Any idea why?
Note: I have other .bat (that do not open html pages) that are successfully executed by Jenkins.
EDIT: here is the errors I get in the prompt log from Jenkins's menu :
C:\Program Files\Jenkins\jobs\JobTest2_enUnSeulScript\workspace>echo "
Opening html page" " >> Opening html page"
C:\Program
Files\Jenkins\jobs\JobTest2_enUnSeulScript\workspace>"C:\Program
Files\Google\Chrome\Application\chrome.exe" "E:\user\Visual
Studio 2010\JenkinsWorkspace\JobTest\testResults.14h05m15s65ms.11.04.2013.trx.htm"
[688:3900:0411/140520:ERROR:gpu_info_collector_win.cc(96)] Can't
retrieve a valid WinSAT assessment.
[688:3900:0411/140520:ERROR:process_singleton_win.cc(540)] Lock file
can not be created! Error code: 32
[688:3900:0411/140520:ERROR:chrome_browser_main.cc(1157)] Failed to
create a ProcessSingleton for your profile directory. This means that
running multiple instances would start multiple browser processes
rather than opening a new window in the existing process. Aborting now
to avoid profile corruption.
Build step 'Exécuter une ligne de commande batch Windows' marked build as failure [htmlpublisher]
Archiving HTML reports... [htmlpublisher] Archiving at PROJECT level
E:\user\Visual Studio 2010\JenkinsWorkspace\JobTest to C:\Program
Files\Jenkins\jobs\JobTest2_enUnSeulScript\htmlreports\HTML_Tests_Report
Finished: FAILURE
If you are running Jenkins as a Window's service, you will probably need to enable the service to interact with the desktop. Do the following:
Open the Services module
Right-click on Jenkins and select "Properties"
On the "Log On" tab, run as "Local System account" and select the "Allow service to interact with desktop" checkbox
-- OR --
You can run Jenkins via the command-line. Ie: "java -jar jenkins.war".
I am guessing that your Jenkins install is running as a Windows Service. When Jenkins is run as a service on a Windows machine it runs under the System account, not a user account. The System account usually does not have the same settings as a user account.
You might want to try starting a CMD shell as the System Account. (The answers to this question should help you with that: How Do You Run CMD under System Account.) From there, try running the batch file and see what happens. You may find that you need to setup somethings like the PATH before it works.
I know this is late, but I just answered another question on how to open an .exe (or .bat) from Jenkins's service on Windows
Open Excel on Jenkins CI
The issue is that while your command actually works, it does that in Session 0 (which is the session of Local System user that launched your Jenkins service), which you cannot see while being logged in through your own user account, most likely in Session 1.
Hope this helps