Automate stuff with Javascript - javascript

I want to automate some tasks as below:
For a particular url eg:www.xyz.com, there are list of tickets nos ..so I want to click, perform an action on it which it will result in different page..and in that page.
I need to check some already filled input boxes depending upon that..I need to add content to some other input boxes and perform submit button.
Can this type of automation be performed in js ..if yes please advise of any framework ..and if no why not and suggest any other language.
I researched quite a bit, I think it can be performed in python, but i prefer any js framework or just vanilla.

Surely you can. This can be achieved using Node.js + selenium-webdriver package to automate what you mentioned.
Here is the API document of selenium-webdriver: https://seleniumhq.github.io/selenium/docs/api/javascript/
Here you can find tutorial on how to create web automation scripts with JavaScript:
BDD Web Automation Tutorial

Related

How to turn a Photoshop script (Javascript) into a plug-in / program with a UI

I'm not a developer so I'm not sure how to properly phrase my question.
As a graphic designer I work a lot on sorting through and processing batches of images through Photoshop to meet specific specs. I wrote/hacked together a short script (Javascript) that runs through Photoshop to accomplish the sorting part of this task.
Rather than opening the javascript file every time, is there a way I can turn it into a little standalone programme or Photoshop plug-in? I want people to be able to see a simple interface of some kind where they can choose certain options (like which folder to run the script on), and then just click "GO".
I'm not sure where to start so even just some links to resources would be great.
I think you have two options: a simple one and a difficult one.
A simple one would be adding an interface to you script via ScriptUI: this way your script can show UI. You'll still need to run the script manually (you can assign it to a hotkey or use in an Action tough) and this is going to block PS UI
A difficult one would be transforming your script to an extension panel: an entity that consists of HTML+JS for UI and JSX for your host app (your script). This way you can have ui for your script always opened and use any your favourite js framework
Note that plugins in Photoshop terminology are compiled C++ entities: believe me you don't want to go that way

Amazon Mechanical Turk: How to use react/redux to implement HIT?

I have implemented a complex interactive HTML form using React and Redux. I want to show this form to mturk workers and retrieve the results as a json string (basically containing the redux state after completion of the form).
After some googling, I see three options how to do this:
1) Use a ExternalQuestion and host it on my own server. However, I can't find an option how to create an ExternalQuestion using the Mechanical Turk web-interface. I only found tutorials that explain how to create such a question using the mturk API. Is there no other way to do this? I want to avoid writing scripts for publishing, retrieving the results and approving the workers myself.
2) Use a pre-defined question type such as "Survey". In this question type I can embed an iframe pointing to my own server where the react app is hosted. Using additional javascript I could retrieve the results from the iframe, store it in a hidden field in the survey and submit that as my final result.
3) Compile my react app, upload the JS and CSS files to my own server, copy the HTML to mturk and reference the JS/CSS from there.
None of these options feels right to me. How can this be done correctly?
I think an ExternalQuestion would be my best bet, but I want to avoid writing my own API calls as bugs could result in money loss.
Option 3 is the typical pattern for this kind of use case.
You can reference your assets and then in your javascript put your submit value in a hidden input within the .
This blog post shows how to achieve a use case like this using Crowd HTML Elements with Amazon SageMaker Ground Truth. It should be a helpful starting point for how to do this using MTurk directly.
Please feel free to reach out to me at samhenry#amazon.com if you get stuck.
Thank you,
Amazon Mechanical Turk

Integration of trello board with django via client side java script

I am integrating existing Django project with another application(trello) via client side script.
In the template, I have a button that triggers a javascript that creates a task in trello.
However, I do not want to create this task more than one time so I am thinking what option should I choose to validate it .
1-To trigger update of the field my Django project
2-To try to read the data from the trello application to check if the id already exists.
Both approaches should work but now I am wondering maybe there some standard approach from Django point of view for this problem?
I had slow ignition . The solution is simple. If you do search for the implementation of "like" button in Django it will achieve the same goal exactly and this topic was discussed in other questions .Django Like Button

JS, HTML,CSS and Python(Django)

I have a form in the html. And obviously an input box with a unique id.
THe uerenters clicks on the search input box and types the query.
Clicks on a button that is linked with javascript to provide js with whatever was entered in the input box.
But I have a python.py file which is where I want to use the term entered by the user.
How do I make the JS interact with Python? Web servers? Sockets? Whatever. Tell me steps.
Now, I have seen answers on SO and links that redirct to google app engine and so.
But If someone could provide me the step wise instructions as to how to get this done, maybe?
You can use web frameworks like Django, web2py. If you do not need a full stack framework, I recommend to you Flask.

How can I get dynamically web content using Perl?

This is kind of tricky. There is this webpage which, I am guessing, uses some kind of AJAX to pull out content based on the search query. When I fetch the page using get in Perl, it fetches the script code behind the php/html, but not the results which are displayed when the query is searched manually. I need to be able to fetch the content of the results page. Is there anyway to do this in Perl?
Take a look at Selenium RC and the WWW::Selenium module in Perl. With them you can control a real web browser.
Another option is WWW::HtmlUnit which uses the HtmlUnit Java library to execute the JavaScript without a web browser. WWW::HtmlUnit uses Inline::Java to give Perl access to the library. I have found that when installing, it is best to say No to the question "Do you wish to build the JNI extension?".
If you are writing tests that need to check the rendered page, you can have a look at Schwern's javascript-tap-harness, which works with Selenium and handles all the scaffolding.
I also found Using WWW::Selenium To Test Or Automate An Ajax Website pretty useful.

Categories