After running the command open -a safari http://localhost:9090 in terminal, I would like to change the opened safari url to a relative address like javascript:foo();, but I couldn't run this url, from the command line, without opening a new safari browser.
You can use applescript for this:
osascript -e "tell application \"Safari\" to set URL of the front document to \"http://www.google.fr\""
Related
I need to open a chrome browser (with full screen + localhost:8080) just after login in Debian 8.0 and I am partially able to achieve same with below command-
#!/bin/bash
sensible-browser 127.0.0.1:8080 ---- this opens the browser with the URL
sensible-browser --kiosk 127.0.0.1:8080 ---- this opens the browser in full screen but not with the URL
I am thinking of alternate approach that if I can set browser default page using command then above line can work to open browser in full screen but don't know how to do it.
Please help. Thanks in advance!
This behavior is due to the sensible-browser command. If you look inside the script (probably at /usr/bin/sensible-browser) you may see that this script takes only the first argument.
You can get the expected behavior by running the Chrome executable, usually named google-chrome.
Either google-chrome '127.0.0.1:8000' --kiosk or google-chrome --kiosk '127.0.0.1:8000' will work properly.
Is there a crossplatform way to open the default browser without a toolbar and point it to localhost, where my app will serve http?
eg in C++, python, golang or java?
On OSX, you can download the chrome-cli:
brew install chrome-cli
chrome-cli open <url> (Open url in new tab)
chrome-cli open <url> -n (Open url in new window)
chrome-cli open <url> -i (Open url in new incognito window)
chrome-cli open <url> -t <id> (Open url in specific tab)
chrome-cli open <url> -w <id> (Open url in new tab in specific window)
On Linux, you will need xdg-open:
sudo apt-get install xdg-open
xdg-open open <url> (Open url in new tab)
I am trying to send xml via NodeJs. My code is
res.set('Content-Type', 'application/xml');
res.send(body);
But chrome says
Unsafe attempt to load URL http://localhost:3030/my-file.xml from frame with URL http://localhost:3030/my-file.xml. Domains, protocols and ports must match.
How can I fix this?
This doesn't work is due to a security concern that Chrome has blocked XML files from accessing local files in the same directory, while HTML files can access.
Workaround:
On Windows: from the command prompt run
C:\Users\USERNAME\AppData\Local\Google\Chrome\Application\chrome.exe --allow-file-access-from-files
(replacing USERNAME with your username)
On Ubuntu:
for chromium browser type
chromium-browser --allow-file-access-from-files
for google chrome
google-chrome --allow-file-access-from-files
Maybe you have to kill all running windows processes for chrome.exe in the windows task manager.
I'm automating web-UI testing using Selenium. All our existing non-UI related tests are executed through CLI by SSHing into the machine, and it would be great if there's a way to execute these UI tests through CLI by having an X-session run in memory. Is there such a thing in Linux?
There is, its called xfvb.
Sure. You can run a VNC server and have your browser display on that. Like so
noufal#sanitarium% vncserver
Warning: sanitarium:1 is taken because of /tmp/.X1-lock
Remove this file if there is no X server sanitarium:1
New 'X' desktop is sanitarium:2
Starting applications specified in /home/noufal/.vnc/xstartup
Log file is /home/noufal/.vnc/sanitarium:2.log
noufal#sanitarium% /usr/bin/env DISPLAY=sanitarium:2 /usr/bin/firefox --ProfileManager --no-remote
Xlib: extension "RANDR" missing on display "sanitarium:2.0".
will run a browser on the VNC
If you want to see it, you can do something like
noufal#sanitarium% vncviewer sanitarium:2
I created a server using Node listening on port 8000, localhost. Verified it's running properly, but I cannot access the WebSocket on the client (Chrome 5). Tried several implementations from various Git repos, node + websocket, socketIO, articles, etc. Nothing.
No port conflicts (sudo lsof -i tcp);
Tried server.listen(8000, "*");
Pointed to ws = new WebSocket("ws://:8000/test");
Debian Lenny, Apache22
Node v0.1.98-31-g1c6671a
I'm thinking there may be a conflict with url rewrite. Or possible permissions. Any ideas?
I had a similar issue on Ubuntu 10.04 LTS 32-bit and Chrome 5.0.375.125 and found out it is a bug in Chrome.
Here's how you can test and work around the problem. I used WebSocket with PHP and later Node.JS:
PHP: Download a tutorial file from http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/ and extract it in a folder called 'socket' in your webroot. This folder now contains a readme.txt and the folders 'server' and 'client'. Now start the script in the console according to the readme (for me the command was: sudo php -q /var/www/socket/server/startDaemon.php ). It should print 'Start listening on Socket.' . Leave the console window open. Now go to localhost/socket/client/client.php in Chrome. It should say 'Socket Status 0' and if you look in the console you see no new messages (no connection was made).
Now here comes the trick: open a second Chrome tab. Point this tab to the same url: localhost/socket/client/client.php (It also says 'Socket Status 0'). And then close it again. Your original tab should now say 'Socket Status: 1 (open)' and in the console you see a handshake was made. WebSocket now works.
I repeated the same trick as above but this time using Node.JS with the Socket.IO script. The chat example included in Socket.IO-node ( github.com/LearnBoost/Socket.IO-node ) had the same issue, hanging at the 'Connecting...' stage. Opening a second tab to the chat box and then closing it again solved the problem and the chat box proceeded to load properly. The Node.JS server confirmed the connection in the console. From then on WebSocket worked fine.