Script take a web survey for me

I had to conduct a survey of supervision today, and the format was as follows: the question was asked, then after pressing the next button the answer was displayed as “Answer: _” along with an explanation. For the punches, I would like to make a program that could conduct this survey, answer any letter, then go to the next page and read the answer, then go back and change the answer to the correct one, and then go 2 pages forward and repeat.

I am familiar with Java and Python, but I'm not sure how to make them “know” where the button is, and how to “read” the text without unnecessary pattern recognition.

This is just a fun project, nothing serious, but I would appreciate any ideas that would help me get started.

0
source share
3 answers

Assuming that the text was just that (text, not images), there are several useful tools for you:

  • .NET WebControl - I wrote this earlier from .Net. The advantage is that all the JS on the page is still working. I know that this is not Java, but it is surprisingly easy to work with this task.
  • Selenium is primarily a web testing environment, but it would be easy to script from Java to auto-submit forms.
  • TagSoup for Java - If the pages do not have meaningful javascript code to run, there are many HTML parsers in Java that could potentially be used to create a scraper.
+1
source

Would it be unrealistic for him to publish a survey page of monkeys? Then you can do some regular expression to pull out the “answer: __” and look for this template on the original page. That would definitely be easier than trying to click things in a browser, etc. Basically, write a java application or python, if so, which does http messages on the survey pages in order and uses regex to find the next page, etc., and then use the stack to track the history.

Change if it is not clear let me know, I will clarify

Edit 2: I completely forgot about HTMLUnit , my bad one. This is a test environment, for example, proposed by jsight, but specifically for Java and features very similar to JUnit, however, since it is designed to test web applications, it can be used to automate interaction with other sites.

0
source

You can do this using a simple image search. First remove the unique part of the button from the screen and save it. This will be used as a relative reference to where you click the mouse. Then, during the actual launch of the application, take a screenshot of the entire screen and find the part corresponding to the previously saved image, and then click on the corresponding location depending on the location of the button image.

-1
source

Source: https://habr.com/ru/post/983520/


All Articles