Native browser tasks automation - javascript

I have some user tasks on the browser that I want to automate. These tasks involve page load/re-load. I am wondering if it is possible to write a javascript code using browser capabilities (like dev tool / local storage) to perform this.
Is it possible to write an extension to do that ?
My flow is the following :
Be on a page that has multiple listings of my own
Loop through each listing to modify it.
Modifying each listing involves
clicking on a button "Modify", which brings user to https://xxxxxx/ modify.
Then do a bunch of clicks on that page (easy).
Then click on confirm which bring user to another page https://xxxxxx/ modify/confirmation.
Please note I am not looking for solutions that involve automation frameworks like Puppeteer or Selinium. I need to have javascript code or chrome extension.
Looking forward for your help
searched the web for two weeks no solutions

Related

Automatize web actions without need to open the browser

I have to execute code of a web page (action of uploading files, a button for a popup, ..) without the need to open the browser, automate it in a code (JavaScript for example). Do you know if its possible and how?
Thank you
Learn how to use Selenium... You can use it in many languages including Node.JS (https://www.npmjs.com/package/selenium-webdriver).
I think program still needs to open web-browser or atleast start it in background but seems this is what you are looking for.

Android app: is it possible to inject script into web browser

I want to create an app which is able to inject a javascript script into a web page when the user clicks an item in the share menu (alternative methods of triggering the app to do this may also be ok).
I've found that adding an item into the share menu is pretty easy using the ACTION_SEND intent.
However, I've done a lot of googling and searching SO, but I can't seem to find any examples of people injecting scripts into an Android web browser, which is why I'm starting to doubt if this is possible.
Essentially, I have a bookmarklet which in injects javascript into whatever web page you're looking at. I want to build an app which does exactly the same as the bookmarklet does. Any alternative suggestions for achieving this would also be interesting to hear.

How to extend HTML of an existing site via JavaScript or similar

I want to add a bit of extra HTML to an existing site based on a REST API call response.
Specifically, www.arbookfind.com lets you search for kids school books with an "AR" test. (My son has to read a certain number of books at a level.) It has a link to amazon.com if you find a book you want to buy. However I would like to know if available for Kindle (most are not). Right now I have to click the Amazon link, check the page, go back and try next one - it can take 10 tries to find one available on the Kindle. Painful!
I was after ideas of the easiest way to do this. That is, without touching the arbookfind.com web site, can I add some JavaScript (jQuery) to all the returned HTML pages. The JavaScript will look in the returned page for each book, fire off a Amazon ItemSearch query (?) to see if available on Kindle, then inject a HTML link to the Kindle book on Amazon. I can learn how to write the JavaScript - I am just after some pointers for the easiest way to augment the current site.
That way I can use the current arbookfind.com site to find a book, but it is faster for me to identify which books are available on Kindle without manually trying each link by hand.
E.g. a web browser plugin that runs some javaScript on each returned page? A varnish proxy with some smart logic to fiddle pages on the way through? A PHP app acting like as a proxy server? Thanks!
Maybe you want to have something like the chrome extension Tampermonkey.
It allows to add and manage userscripts for websites. Means, a javascript "snippet" which is added to websites maching specific patterns.

Managed code for test Automation for Java based web application

The following might be a generic question, but I was to curious to learn if there are any possibilities
Currently there are many web applications and as part of test automation for them, several tools are being used for record and playback and such tools which are used for automation, will record the UI on the browser and while interacting with elements or controls on web page, the tools use xpath or some other identifiers to generate code and such code is less stable and may not provide seamless interaction. Many a time, the playback of such scripts sticks and may not be able to find the element or may not be able to click the controls such as buttons or checkboxes or images or radio buttons or hyperlinks etc. Sometimes, the automation script execution/playback goes unbelievably slow or times out.
Often, the web UI automation scripts lose focus during playback. For example the
script must a click button A, but it clicks the adjacent buttonB,
the script must be clicking menu itemA, but clicks menuItemB to launch pageB instead of page A
which indicates that the script execution and application are going out of sync
The behavior of these scripts also differs in different browsers. The recording is only possible when the application is up and a particular page launched
So, I was just curious to know if there is any way to overcome the problems mentioned above.
I mean is it possible to hand code the scripts in such way the recording is not required, but the scripts are ready with a managed code even before the application/web page is not launched, thus keeping a seamless and stable interactions between the script and the browsers/web applications.
Have you looked at Selenium? http://docs.seleniumhq.org/
It allows for automation and you can record the scripts using the GUI, but then you can manually modify the code generated for the scripts to point to the right things if the recorder gets it wrong.
Not sure if this fits with what you are trying to do, but I've used it before to automate some tasks on a browser and it worked really well.

How do I use Mechanize to process JavaScript?

I'm connecting to a web site, logging in.
The website redirects me to new pages and Mechanize deals with all cookie and redirection jobs, but, I can't get the last page. I used Firebug and did same job again and saw that there are two more pages I had to pass with Mechanize.
I took a quick look at the pages and saw that there is some JavaScript and HTML code but couldn't understand it because it doesn't look like normal page code. What are those pages for? How they can redirect to other pages? What should I do to pass these?
If you need to handle pages with Javascript, try WATIR or Selenium - those drive a real web browser, and can thus handle any Javascript. WATIR Classic requires either IE or Firefox with a certain extension installed, and you will see the pages flash on the screen as it works.
Your other option would be understanding what the Javascript on the offending page does and bypassing it manually, but that seems onerous.
At present, Mechanize doesn't handle JavaScript. There's talk of eventually merging Johnson's capabilities into Mechanize, but until that happens, you have two options:
Figure out the JavaScript well enough to understand how to traverse those pages.
Automate an actual browser that does understand JavaScript using Watir.
what are those pages for? how they can redirect to other pages. what should i do to pass these?
Sometimes work is done on those pages. Sometimes the JavaScript is there to prevent automated access like what you're trying to do :). A lot of websites have unnecessary checks to make sure you have a "good" browser, so make sure that your user_agent is set to something common, like IE. Sometimes setting the user_agent to look like an old browser will let you get past without JavaScript.
Website automation is fun because you have to outsmart the website and its software developers, using multiple strategies. Like the others said, Watir is the best tool for getting past JavaScript at the moment.

Categories

Resources