Automating browser from terminal - linux

Is there a way to automate a server so that it can open browser at a specific time and input a given email in a form then submit it.

Yes, It can be done by using headless browsers as suggested by #TNU, I have done it using Phantom Js, Now there are many ways you can do this.
Just write a javascript in a file and schedule the job using cron from terminal.
Or you can use casperjs another library written on top of phantom Js.
Or you can use Ghost driver for connecting to phantom headless browser to execute and schedule the scripts.

Yes, you could use headless browsers, which don't have user interfaces and can be controlled programmatically. Check this list for a list of Headless Browsers

Related

Controlling two chrome instances through Cucumber scenario, driven by Watir Webdriver

I am working on a web application, where I receive a phone call, which is initiated by another web application. To achieve this, I need to open two chrome browsers having two different URLs. I am using cucumber to write scenario and watir webdriver to drive the script. I have implemented Page Object Model as a part of framework. I tried making some changes to support files - i.e., hook.rb, env.rb and driver.rb. But it's not working out. Is there a way to achieve this?

What's the status of the WebExtensions' background page implementations by browser/OS

In Chrome for Win/Mac/Linux it is possible to have browser addon scripts running before the user launches the browser and after they shut the last browser window. In Chrome this is done by claiming the background permission - see the Chrome extensions API docs on background. Other browsers don't seem to support this permission. So my questions:
Is this also possible with other browsers (e.g. by using some other permission/API...) and with other operating systems (specifically Android/iOS)?
What is the behavior of this feature across different operating systems? (I have tried it with Chrome on Ubuntu and while Chrome does continue running and the script keeps performing its task, it doesn't automatically start in background after restarting the OS - I guess one would have to manually add an autostart script for that)
What I'm trying to accomplish is something similar as to what as been asked here: Display a Chrome desktop notification every day at specific time. But I want to learn about cross-browser-and-OS-compatibility before putting too much effort into it. Also an outlook for what's going to be possible in the near future would be nice. :)
(I am aware that something like this could be done using push notifications, but I would also like my app to work offline, so that's not an option.)

Execute Javascript on a Website via script

Hello!
So, when I open a Website in Chrome and press F12 I can open up the console and type in commands. I want to do the same via a script, maybe something like Node.js. I want go to any Website I want and execute console commands in my script.
Is that possible? Is there an API I have to use?
Thanks for the help! :)
You are probably looking for page automation, if you are familiar with javascript you can use PhantomJS. Take a look at page automation using PhantomJS here.
If you want to go with progamming languages like Java,C#,python,etc you can use Selenium.
check puppeteer. you can evaluate script in the context of the page

mocha testing with later DOM element interaction

In my unit tests I am calling an API whose response is a webpage with buttons and textboxes. Is there a way to simulate click events or keyboard event with the webpage?
The way to go for Browser testing is using a headless browser, like PhantomJS http://phantomjs.org/headless-testing.html
There are instructions available for setting up tests with various test frameworks.
Headless Browsers are similar to "real" Browsers but meant for programmatically controlling them.

How can I programmatically control a browser such as chrome in linux and execute javascript per each tab?

I have been given a task of toggling nearly 200 users' permissions in an admin. I have access to the database, and I'm sure I can do this in SQL but I'm curious to find out how to do it this way as well, plus I suspect it will be less work because I don't have to study the SQL that's going on and I know exactly what to do after I get access to the browser instance and know how to execute javascript programmatically in the context of the web page open.
I basically want to provide a list of urls which will open ( 195 ) and then execute javascript to toggle checkboxes, then submit the form.
As I stated, I want to use firefox or chrome and I'm on linux.
This is basically what greasemonkey does.
Or, if you can do it all while staying on the same page, you can also just type in arbitrary JS code by hand in the firebug console or its Chrome equivalent. This could work if combined with some iframe trickery.
If you use Chrome, it has built in support for user automation scripts: http://userscripts.wikidot.com/, http://www.chromium.org/developers/design-documents/user-scripts
I think a cleaner solution would be for you to figure out what is the url and the parameters to pass to do what you need. Then you can just use curl to make those requests.
I use CJS Chrome extension. I add a short script take loads a script from my localhost server and executes it. The executed script can also send results back to the server.

Resources