Is there an option to enable json-loading from HDD in Chrome or Internet Explorer? - json

Is there an option to enable Chrome or the Internet Explorer to load (via ajax-get) an JSON file from the local harddisk?
Firefox does so by default. Internet Explorer says 'premission denied' at the line
request.open(method, url, true);

There are no simple cleaner way you can do this, you have to do some server-side coding.
I suggest you node.js this is very handy for this type of IO operations.
It looks very difficult for first time but it is very handy.
Download and install nodejs.
create a simple project to handle this.
In the directory you want files to get (e.x. D:\myfiles), create one file server.js, content of that js file would be following
var connect = require('connect');
var serveStatic = require('serve-static');
connect().use(serveStatic("./")).listen(105);
open command promp from and get to this directory (D:\myfiles)
Run these two commands npm install connect and npm install serve-static (up to this, is one time process)
Run node server.js - That's all your server is ready and running
call http://localhost:105/<file name> and you can get any files within that directory.

For chrome you can use following command line flags, taken from following question
--allow-file-access-from-files
--disable-web-security
As noted in that question you need to restart your all chrome browsers.
For internet explorer, trick is to use ActiveX version of the XMLHttpRequest object.
See following link.
https://social.msdn.microsoft.com/Forums/ie/en-US/9ae077e0-a7b9-433f-835f-2643aa1a7e09/ie11previewcannot-read-local-files-with-ajax-method-of-jquery?forum=iewebdevelopment

Related

chrome : unable to read local files by using `-allow-file-access-from-files `

Introduction
Honestry,I'm not native English user,so my English is not better.
If you have any question, ask me by comment.
what I wanna do
As a premise,when you try to access local files by web site link,IE or FireFox can access( by simple setting) ,but Chrome can't access for their security poricy.
I found the ways to do this, like below:
add --allow-file-access-from-files option when you execute chrome.exe
build a local server like nginx or Apache HTTP Server,which meditate to access local data
Use chrome extentionEnable local file links
Due to business restrictions,I should resolve this problem by method 1. but I can't enable loacl data link though I set option correctly.
I googled why I can't,but I couldn't find why it won't work.
(In the first place,I can't even find Google official description of --allow-file-access-from-files.How predecessors find that method ... )
While searching、I found person who have the same question、Google Forum.
I'm convinced that this is not my simple miss,but more deep problem,so I decided to make this question.
what I tried
I rebooted computer,killed all process related to chrome,then change directory where contains chrome executable file,and execute chrome.exe --allow-file-access-from-files
I rebooted computer,killed all process related to chrome 、create shortcut on my Desktop ,which destination is "/path/to/chrome/chrome.exe"--allow-file-access-from-files
After execute chrome,I checked chrome boot option to accesschrome://version/.Both method, I could boot chrome by add --allow-file-access-from-files option,but can't achieve first purpose to access local file access.
what I wanna know
lacking or similar to --allow-file-access-from-filesoption、
(solution similar to method 2 or method 3,like "Give up option solution,and use nginx as local server" is unnecessary)
or other solution
Additionary,if you know below info,please teach me.
- Google official documentation which descriptionsallow-file-access-from-files
( Indended to Oracle official Javadoc of Java.)
Using Tool
Chrome Version : 78.0.3904.87
OS : WIndows 7 SP1

Is transcrypt supposed to run from the local filesystem?

I've installed Transcrypt, compiled the Hello Solar System demo, and run it as instructed using the python web server.
However, I was also able to run the hello.html file directly from Chrome on Windows 10 ... once. Subsequently it refuses to run - the buttons appear but clicking them does not update the text.
------- EDIT ---------
Thanks - CORS is the problem - the browser must connect to a web server, not a file on the local filesystem.
You've probably run into a security policy of Chrome called CORS. Start a webserver from the directory where your html file is, using python -m http.server, and browse to localhost:8000. In your browser window, click on the html file and things should work.

Default location of ChromeDriver binary and Chrome binary on windows 7

What is the default location of ChromeDriver binary and Chrome binary on windows 7 for triggering appium using java-client.jar? if i am using RemoteWebDriver and tries to initiate chrome browser, from where does the selenium initiates the chromedriver?
the code:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("userName", ReadProperties.Properties("MobileUsername"));
capabilities.setCapability("password", ReadProperties.Properties("MobilePassword"));
capabilities.setCapability("udid", ReadProperties.Properties("MobileUID"));
capabilities.setCapability("browserName", ReadProperties.Properties("MobileBrowser"));
capabilities.setCapability("platformName", ReadProperties.Properties("MobilePlatform"));
log.Info(capabilities.getVersion());
mobile_driver = new RemoteWebDriver(new URL(""+ReadProperties.Properties("MobileURL")+"/wd/hub"),capabilities);
chromedriver is not installed in your System by default. Users individually have to download chromedriver from ChromeDriver - WebDriver for Chrome page and you can place it anywhere within your system.
You must ensure that Chrome is installed at the optimum location as the server expects you to have Chrome installed in the default location for each system as per the snapshot below :
Note : For Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary. You can also override the Chrome binary location following the documentation Using a Chrome executable in a non-standard location.
The location will depend on your default download folder e.g. when you download something from the internet and it goes into the downloads folder, then that is your default download folder.
So if you downloaded chromedriver.exe the same way, then it will also be in the downloads folder.
If you are using 3rd party service to run your tests you should not care about chromedriver.
But when you run tests locally you have to download it yourself: https://chromedriver.storage.googleapis.com/index.html
And then use capability to set absolute path to this file.
Make sure you use chromedriver version compatible with your browser version.
I know it's an old question but none of the answers above helped me. I found a different solution that worked for me and it might help someone else in the future.
I have tried the below solution with only Windows 10 / Server 2016.
Step 1: Get to the Google Chrome install directory by right clicking on the Chrome icon and click on Properties. You will see the installed directory listed under 'Target' and 'Start in' options. The directory path should end with .../Chrome/Application/. Copy the whole path.
Step 2: Open File Explorer and go to the above copied path. You should see chrome.exe file with other files and folders. Copy the whole Application/ folder including chrome.exe file with other files and folders.
Step 3: Go to the below file path and paste the above Application folder.
C:\Users<YOUR USER>\AppData\Local\Google\Chrome\
After pasting the Application folder, you should have the chrome.exe file with other files and folders in the following file path:
C:\Users<YOUR USER>\AppData\Local\Google\Chrome\Application\
Now the ChromeDriver should be able to locate the Chrome Binary.

Where is chrome.storage.local stored for Chrome Apps?

Where is chrome.storage.local stored for Chrome Apps in OSX yosemite?
I finally found it: ~/Library/Application Support/Google/Chrome/Default/Local App Settings/{{chrome-app-id}}. The whole {{chrome-app-id}} folder is a leveldb database. I was able to open it and inspect the contents of the stored file using the leveldb-ruby gem. Just do the following
require 'leveldb'
db = LevelDB:DB.new '~/Library/Application Support/Google/Chrome/Default/Local App Settings/{{chrome-app-id}}'
You can now query the database using the db object. By the way if you get a weird error saying that the db is being used by someone else make sure you kill chrome and erase the LOCK file.
localStorage is located in ~/Library/Application Support/Google/Chrome/Default/Local Storage. You'll need the ID to find the correct files but they'll be prefixed with chrome- and have a file extension of .localstorage.
Based on some picking through the POSTMan App, it looks like it makes a call to chrome.storage.local and the data on my Mac is located here: ~/Library/Application Support/Google/Chrome/Default/Local App Settings/<ID>/000003.log.

Open URL in Chrome & save its source code using Command prompt

I am having a hard time to find how to save the page as html or .txt using command line in Chrome Browser,
This is what I've done so far,
C:\Users\Cipher\AppData\Local\Google\Chrome\Application>chrome.exe --new-window
http://google.com
This command will open a new window of Chrome browser and visit google.com but i couldn't be able to figure our how can i save google.com as html or as txt file ,
is there anyway to do so using command prompt ?
You cannot perform the task you describe manually, but you can perform it using WebDriver automation.
Chrome can be remote controlled using an API called WebDriver (part of Selenium 2 automating suite). WebDrive has bindings for various programming languages, including e.g. JavaScript and Python.
Here is example code for Python (not tested):
from selenium import webdriver
driver = webdriver.Chrome('/path/to/chromedriver') # Optional argument, if not specified will search path.
driver.get('http://www.google.com/');
html = driver.page_source
f = open("myhtml", "wt")
f.write(html)
f.close()
Orignal example
Do you really need to open Google Chrome? You can get the page source using Wget (available for UNIX systems or for Windows in this post on SuperUser). Once installed, just use the following command:
wget http://google.com -O yourfilename.html
And this should be all :) I don't think there's a way to tell Chrome to download the HTML from the command line though :(
UPDATE: There's a repo on GitHub called chrome-cli that allows the user to control Chrome from the command line. Downside is that it only works on Mac OS X.
I created a small script to do perform exactly this task: https://github.com/abiyani/automate-save-page-as . See the demo gif in the README.
It automates the keyboard actions you would otherwise perform to save the page manually (literally sends those key signals to OS). As a side effect of it being used in another project of mine, it's been tested on various linux flavors: Ubuntu, Mint, Fedora, etc - and works fine on all of them. It probably won't work (at least without modifications) on Mac, and certainly not on Windows.
This should work :
cd c:\Program Files (x86)\Google\Chrome\Application
c:\Program Files (x86)\Google\Chrome\Application>chrome.exe --headless --dump-dom --enable-logging --disable-gpu https://www.google.com >c:\yourpath\yourfile.html