How do you run Chrome while selenium headless script is executing on mac?
I have a python selenium script that uses chromedriver in headless mode to test links on a website. I'm running this script on MacOS High Sierra.
If I have Chrome open prior to running the script, I can continue to use the browser normally. Headless mode appears to isolate me from the testing. However, if Chrome is closed first, I cannot launch the browser while the selenium script is running.
Looking at Activity monitor in the first scenario, it appears to me that chromedriver creates a new process for Chrome to run. So I (perhaps incorrectly) assumed I should be able to launch the browser manually while the script is running.
What am I missing?
How do I launch Chrome while selenium is running on Mac?
1 answer
-
answered 2018-12-05 20:47
Marcel Wilson
Ah-HA!
This post I stumbled upon made it possible to open Chrome while selenium is running (although I don't understand why it works one way but not the other).For most applications, launching with
open -naF "App Name"
oropen -nF /path/to/application.app
should be sufficient (see Safari, Forklift, Office apps, etc.).-n
opens a new instance-a
tells open to look in the list of registered apps (no need to specify the full path, but can go wrong if you have multiple versions of an app. I sometimes see issues on my system with differentiating between macOS apps and apps installed by Parallels OSes… I prefer to specify the path directly.)-F
opens a fresh instance (ignores an app save state left over from previous instances)
See also questions close to this topic
-
web cam in a webpage using flask and python
I have created a face recognition model using keras and tensorflow, and now I am trying to convert it as a web application using flask and python. My requirement is that, I need a live webcam displayed on the webpage and by clicking on a button it should take the picture and save it to a specified directory, and using that picture the application should recognize the person. if the person is not found in the dataset then a message should be displayed over the webpage that unknown identity is been found. To do this job i have started learning flask and after that when it comes to the requirement it was very difficult for me. somebody help me out to solve this situation.
-
pandas df - sort on index but exclude first column from sort
I want to sort this df on rows but I want to exclude the first column from the sort so it remains where it is:
Radisson Marriott Hilton Accorhotels IHG Category good job 0.214941 0.40394 0.448931 0.314185 0.375316
expected output:
Radisson Hilton Marriott IHG Category good job 0.214941 0.448931 0.40394 0.375316
I don't know to edit my code below to exclude the 1st column from the sort:
df = df.sort_values(by=[df.index[0]], axis=1, ascending=False)
-
How implement this distribution in my model?
I have a NN model that classify statements between 3 categories [-1, 0, 1]
stop = EarlyStopping(monitor='val_loss', min_delta=0.01, patience=15, verbose=1, mode='auto', restore_best_weights=True) model = Sequential() model.add(Embedding(num_words, EMBEDDING_DIM, input_length=MAX_SEQUENCE_LENGTH)) model.layers[0].set_weights([embedding_matrix]) model.layers[0].trainable = False model.add(Dense(300,kernel_regularizer=regularizers.l1(0.000001))) model.add(Dropout(0.35)) model.add(Dense(200,kernel_regularizer=regularizers.l1(0.000001))) model.add(Dropout(0.35)) model.add(Dense(100,kernel_regularizer=regularizers.l1(0.000001))) model.add((LSTM(50, dropout=0.1, recurrent_dropout=0.1)))#, kernel_regularizer=regularizers.l1(0.00001)))) model.add(Dense(1,kernel_regularizer=regularizers.l1(0.000001))) model.add(Activation("tanh")) model.compile(loss="mse", optimizer="rmsprop", metrics=["accuracy"])
After training I use model.predict() to "predict" new values and I got this
array([[ 0.82085645], [ 0.8304224 ], [ 0.8198626 ], [ 0.8128166 ], [ 0.1621628 ], [ 0.74597526], [-0.59259003], [-0.57140785]], dtype=float32)
Ok, here is my first question. How do I interpret this? My first thought was
predictioncm = model.predict(texts_test) predictioncm1 = [] for p in predictioncm: if p<=0.5 and p>=-0.5: predictioncm1.append(0) elif p>0.5: predictioncm1.append(1) else: predictioncm1.append(-1)
But the thing is...when I assign:
predictioncm = model.predict_proba(texts_test) predictioncm1 = [] for p in predictioncm: if p<=0.7999 and p>=0: predictioncm1.append(0) elif p>0.7999: predictioncm1.append(1) else: predictioncm1.append(-1)
This "fit" perfect with the outcome that I want (the statements are from a test set, that's why I know the result). So the results are totally skewed to 1. So my second question is.. Is it possible assign this weights to my primary model to get those values directly or a way to justify this assignment? or do I have to keep the result from my first thought because is the "correct"?
-
Chartjs animate x-axis displaying data incorrectly in mac device
I am working with chartjs, I am trying to animate chart from right to left or left to right on load.
var canvas = document.getElementById('chart_canvas'); var ctx = canvas.getContext('2d'); // Generate random data to plot var DATA_POINT_NUM = 10; var data = { labels: [], datasets: [ { data: [], }, ] } for (var i=0; i<DATA_POINT_NUM; i++) { data.datasets[0].data.push(Math.random()*10); data.labels.push(String.fromCharCode(65+i)); } var oldDraw = Chart.controllers.line.prototype.draw; Chart.controllers.line.prototype.draw = function(animationFraction) { var animationConfig = this.chart.options.animation; if (animationConfig.xAxis === true) { var ctx = this.chart.chart.ctx; var hShift = (1-animationFraction)*ctx.canvas.width; ctx.save(); ctx.setTransform(1, 0, 0, 1, hShift,0); if (animationConfig.yAxis === true) { oldDraw.call(this, animationFraction); } else { oldDraw.call(this, 1); } ctx.restore(); } else if (animationConfig.yAxis === true) { oldDraw.call(this, animationFraction); } else { oldDraw.call(this, 1); } } var lineChart = new Chart(ctx, { type: 'line', data: data, options: { animation: { duration: 5000, xAxis: true, yAxis: true, } } });
The above code works fine on windows, but I'm facing issue on mac devices.While animating from left to right the data displays incorrectly means that the data moves to upward from x axis.How to fix this issue? I am attaching screenshot.
-
Mac OS AVFoundation AVCaptureSession can not start an uvc webcma
I use AVFoundation to start a uvc camera, I have two uvc camera, one camera's Transmission mode is Isochronous transmission ,and the other is bulk transmission. when I use [self.mCaptureSession startRunning] , the camera who's transmission model is Isochronous can run and I can get the buffer in delegate, but the other uvc camera will never call the delegate. so why the same code can show different phenomenon. Every answer can help, thanks.
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { self.mProcessQueue = dispatch_queue_create("mProcessQueue", DISPATCH_QUEUE_SERIAL); NSError *error = nil; self.mCaptureSession = [[AVCaptureSession alloc] init]; AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; NSLog(@"localizedName:%@",device.localizedName); AVCaptureDeviceInput *deviceInput = [[AVCaptureDeviceInput alloc] initWithDevice:device error:&error]; if(!error) { if([self.mCaptureSession canAddInput:deviceInput]) { [self.mCaptureSession addInput:deviceInput]; AVCaptureVideoDataOutput *videoOutput = [[AVCaptureVideoDataOutput alloc] init]; [videoOutput setSampleBufferDelegate:self queue:self.mProcessQueue]; if([self.mCaptureSession canAddOutput:videoOutput]) { [self.mCaptureSession addOutput:videoOutput]; [self.mCaptureSession beginConfiguration]; if (![device lockForConfiguration:&error]) { NSLog(@"error:%@",error); [self.mCaptureSession commitConfiguration]; //break; } device.activeFormat = device.formats[0]; [device unlockForConfiguration]; [self.mCaptureSession commitConfiguration]; [self.mCaptureSession startRunning]; NSLog(@"run"); } } } else { NSLog(@"error:%@",error); }} - (void)captureOutput:(AVCaptureOutput *)output didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection { NSLog(@"sssss");}
-
where is the font file on Mac
Some fonts in mac build-in App, Font Book, are localizable, e.g. the Arail's location is /Library/Fonts/Microsoft/Arial.ttf, but some fonts are different,e.g. Font Book
we can't get the location of the Weibei SC Bold font.
where is it? and why?
-
RSelenium with Docker. Error in checkError(res)
Following documentation online for using RSelenium with Docker, I have installed Docker Toolbox and RSelenium.
In the Docker Toolbox, I run
$ docker run -d -p 4445:4445 selenium/standalone-chrome
and
$ docker ps,
and get the following output.
Then, I run the following in R:
library(RSelenium) library(Rvest) #not sure if I need this? #192.168.99.100 is my IP remDr <- RSelenium::remoteDriver(remoteServerAddr = "192.168.99.100", port = 4445L) remDr$open()
but I get the error
Error in checkError(res) : Undefined error in httr call. httr output: Failed to connect to 192.168.99.100 port 4445: Connection refused
The only things I can think of that is causing this, is that I'm not using Toolbox correctly (need Docker for Windows instead), or that the default path in the path argument to remoteDriver() is not right.
I am running on Windows machine, but don't have Windows 10 pro.
Anyone got any thoughts?
-
How to automate QR code scanning using selenium python
Can anyone tell how can we automate the process of scanning QR code from a website using selenium webdriver with python.
-
Selenium work as user but not as root (sudo)
I use selenium (with firefox) on python. My project works when I launch it in user: "python3 test_selenium.py" but not in root (sudo) : "sudo python3 test_selenium.py"
Error:
"/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/webdriver.py", line 174, in init keep_alive=True) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in init self.start_session(capabilities, browser_profile) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: invalid argument: can't kill an exited process
Thanks
-
Chrome Developer Tools my5.tv website always throws debugger
I am trying to find out how to override the loop of Chrome Developer Tools debugger that always happens on the my5.tv website. Example URL is https://www.my5.tv/peppa-pig/season-5/stamps
When you open Chrome Developer Tools on this page you are flicked to the sources panel and shown a debugger, if you press continue or skip it continues to popup again and again on a loop.
If anyone can lend any advice on how to stop this either by overriding or some other way so I can actually use the developer tools.
-
How we can tweak the network speed of chrome using selenium?
I've few tests to verify on very slow network. I looked around web but could not able to land on appropriate solution. Thanks in advance if any one out there can help me with this.
-
How many levels of Cache for a Joomla Page
Whenever I change something on a Joomla page, like an image, CSS, or whatever, I have to refresh the page in Chrome with ctrl-shift-r.
I'd like to disable any cache, so that I don't have to do that.
How many cache places do I need to disable?
- server cache
- joomla cache
- browser cache
?, do I have to disable the browser cache aswell?
..or can I set a timeout on all items?
Any pointers as to what I can try?
-
Selenium Chromedriver issue after Windows 10 1803 update
After latest Windows 1803 Update. We are facing issue with selenium scripts launching chromedriver.
If scripts are put for overnight executions, after some time scripts starts failing with below exception of webdriver
org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start
Below are the dependency versions used
Selenium : 3.141 Chromedriver : 2.46 Chrome Version : 72 Java version : 1.8.0_201
Please let us know if anyone encountered above issue after Windows 1803 upgrade
Regards, Naveen