script to click a link at a certain time - webbrowser-control

I am interested in writing a script that goes to a website and clicks a link at a certain time. How do I go about doing something like this?

You should use selenium http://seleniumhq.org/
You can control it using anyone of the language you specified in the tags.
You can start to browse from
http://seleniumhq.org/projects/remote-control/

"clicking a link" could have two meanings:
Actually clicking the link in a browser, or just doing an HTTP GET that would result from it. This could be as simple as software that runs on your desktop and simulates a click at a certain point, to something as complicated as Selenium for automation of website interactions.
If you just need to do the GET request that clicking the link would do, anything would do. Unix systems typically include wget and curl, which take a url to request. Or if you want to process the data, you can do this in most programming languages. For example, in python you could do urllib2.urlopen('http://stackoverflow.com') and then do whatever you want with the data. Perl has an equivalent.

Are you familiar with cURL?

Related

Selenium - Avoid getting CAPTCHAs

I'm trying to scrape a login-only, bot-sensitive website. After logging in, when I perform a simple selenium function like driver.find_element_by_id('button').click(), the website displays a message along the lines of We think you are a bot. Please complete the CAPTCHA below to continue.
Is there any way for me to make selenium more human-like so I don't trigger CAPTCHAs?
Hopefully not.
You are scraping, i.e. you are developing a bot, and if you try to avoid being identified as a bot, it will just be a question of time until the captcha gets improved to detect your strategy.
DonĀ“t do it. The captcha is there for a reason, which is: to detect and lockout bots!
Better check if the page you want to scrape supports an API that allows computer-to-computer communication. If there is one, use it. If there is none, suggest one, but depending on whether the web page owner wants to support your goals, or not, he might say "no".

Synchronise user input during cross-browser testing

Are there any tools available that allow user input to be synchronised between browsers during manual cross browser testing?
For example, mouse clicks, data entry into a form etc.
Information:
This sort of functionality was described by Mads Kristensen in a recent DotNetRocks podcast. He outlined a BrowserLink extension he had created (around 11:00) that demonstrated this during a recent talk. However I'm unable to find any other reference to it, and would like to know if any other alternatives exist.
Could you explain how you mean 'synchronise'? As in, it needs to happen on each browser at exactly the same time? Or you just want a consistent set of data used and the timing to be the same for each test?
If the latter, I'd suggest looking at something like Selenium WebDriver. I know this is more automated, but you can't get something exactly consistent if you're doing it manually.

How to simulate 20 users click a button at the same time in Web GUI Test Automation

Now I hava a requirement about Web GUI TA
I want to simulate some users(20-30) click a button at the same time and evaluate the performance of Web GUI at that time.
I use RobotFrameWork + Selenium library to do the Web Gui TA before, but as far as I know. selenium library only can handle one broswer at one time, so i dont know how to do now.
Can you give me some advice? need use another library or framework?
Like mentioned by other, what you want to do in this case is not UI testing but rather stress/load testing. You should be able to try easily Gatling. First you record the http request associated with the click on your button. Then, you write a simple scenario that launches this request 20 times at once. Something like:
setUp(scn.inject(atOnce(20 users)))
.protocols(httpConf)
Selenium has a "grid" option you can use to configure many instances running many browsers.
http://www.seleniumhq.org/projects/grid/
http://www.seleniumhq.org/docs/07_selenium_grid.jsp
Grid allows you to :
scale by distributing tests on several machines ( parallel execution )
manage multiple environments from a central point, making it easy to
run the tests against a vast combination of browsers / OS. minimize
the maintenance time for the grid by allowing you to implement custom
hooks to leverage virtual infrastructure for instance.
In short, you create a "hub" that manages things, then each "node" can perform tests as required by the hub.
Consider, however, this may not be the best route to go down. Something like multi-mechanize might be more useful: http://testutils.org/multi-mechanize/
That will allow you to have many users "clicking" the button, but not via a browser but via direct HTTP calls. That might be more suitable for multi user simultaneous "headless" load testing, which is what I think you are attempting to do.
I'm slightly confused at this question:
Are you wanting to test the GUI? If it's something like "This button makes a dropdown menu appear", then it doesn't matter how many users do it at the same time, it'll either always work, or never work.
Are you wanting to test the server under load? If so, then Selenium will work, but there are better tools. I have used JMeter with success, but there is a really good listing of all of them here: http://performance-testing.org/
Finally, are you wanting to press 20 different buttons on the same page on the same browser at the same time? If so, this isn't possible with selenium, and it isn't a standard use case either.

Smart card, PIN, Secure HTTP, Login and Downloading and manipulating the source html - need a suitable coding langugage

I am now motivated to explore a coding language so that I can make the best solution possible.
But I am not sure of the capabilities of all coding langugages, so I am asking for advice.
I want to automate some of the daily processes I do at the office. There is an external database on the internet that we use. We access it with a smart card and secured http.
In short, these are the actions that I do each time I restart the browser or a session ends:
Open a Secured HTTP. /....jsp
After being promted I choose an installed certificate
A smart card is called and I enter a PIN. /charismatics smart security interface/
The page asks me to log in with a username and password.
I open the desired link.
I extract the data from the opened webpage manually.
Is it possible to have all these action automated by code?
THANK YOU FOR ANY SUPPORT
If you get a PIN screen from the charismatics smart card security interface instead of from the operating system then it it may be very hard to automate this. Your program is unlikely to get access to the PIN popup Window.
If you get the PIN prompt from a CSP (as you mentioned in the comments) then it may be possible to automate the PIN login. The PIN is normally used to set up the SSL/TLS connection, so having it open in the browser won't help you much, unless you program the browser itself.
If you are bound to CSP's it may be best to keep to C#/.NET. There are of course bindings for other runtimes, but it is better to have as much control as possible.
You may want to take a look at topics such as parsing HTML, because that's something you certainly need to do. Life becomes a lot harder if the web-pages are filled in using JavaScript, so you may check for that first.
Now if you want to manually choose a link you may want to render the page in your own application and handle the download yourself.
This is certainly not a task I would recommend when starting off on an unknown programming language. I would find this a tricky task - there are a lot of ifs left with this description.

Software Automation tool

At my company, we have to fill out a daily timecard, and I want to automate it.
I want to use some sort of tool that will allow me to write something like this:
Launch Firefox
go to www.example.com/timecard
Wait for page load complete
In UserName box: put username
In Password box: put password
Press enter
Wait for page load complete
if login failed
email me#example.com that unable to automatically do timecard, please check password
return;
Get today's date
if today is Saturday or Sunday
close firefox
return;
find the timecard column that matches today's date
find the row with the right charge number
put in 8.0 hours
click "Save" link
close firefox
return;
It would be really nice if the software solution will also execute itself daily at a given time.
Since you are asking about UI automation you might want to check out AutoHotKey.
It's a macro language and you can compile the code into executable binaries (.exe).
However, sending web request could be done better without a browser by sending the necessary HTTP requests. Such an approach is more light-weight, more flexible and probably easier to maintain as well.
Check out the Chickenfoot extension for Firefox. I believe it may help you a long the way.
Chickenfoot is a Firefox extension that puts a programming environment in the browser's sidebar so you can write scripts to manipulate web pages and automate web browsing.
It also provides a basic record feature, and you can then fine-tune the interactiosn with the web page(s).
If all you need to automatize is related to browsers, then you may try out Selenium Remote Control which provides libraries in different languages.
For browser automation, there are a couple more experimental libraries in javascript (you should search for web app testing tools as these are imo your best bet for now)
./alex
For decision making, you might have to write some code.
iMacros for firefox has the ability to record/playback.
I have not used it myself but I have heard good things about Selenium. This is a Web UI testing tool that can be scripted in a number of different languages.
I would try to accomplish this with twill.
If by "some sort of tool" do you mean something like a programming language or environment that will allow you to automate what FireFox does? If so, I recommend learning how to write a FireFox extension. Extensions are written in Javascript. See https://developer.mozilla.org/en/Extensions
--
bmb
You could use selenium or watin on a simple .net console program. Then configure a task on window to call it at a given time of day.
If you are using Linux you could easily do this with a bash script of some kind. Have a look at the CURL library.http://curl.haxx.se/. You could then schedule the script to run with cron.
This is why I love Linux, the above is simple to do. I windows I suppose you could use the windows shell. I think the curl library runs on windows.
Selenium (www.openqa.org) tools will work for you. Install the Selenium IDE and record the macro. The "code" is simple JavaScript/HTML.
Selenium RC provides a very strong solution for automated testing from a variety of languages and tools.