I need to create a user journey such as :
User is on the home page --> randomly clicks on particular item --> views the item stays for about 10 seconds --> then again goes back and clicks on another random item.
how do i generate a test script using jython? I am using Grinder tool
Shashank,
I think your question is too broad to get a detailed response. If you ask a more specific question I think you will get a better answer.
I would say there are two general approaches available for doing what you want, and you could have success with either option:
Write your test directly in Jython. The script documentation (http://grinder.sourceforge.net/g3/scripts.html) and script gallery (http://grinder.sourceforge.net/g3/script-gallery.html) will be helpful to you in this.
Using the HTTP proxy, perform the actions in a web browser that you wish your test to perform. (http://grinder.sourceforge.net/g3/tcpproxy.html) The proxy will capture your browser actions and convert them into a Jython script. After this happens, a small amount of additional work will be required on your part to modify the generated script to detect the list of items available and randomly select one.
My own personal preference is to code up the Grinder scripts from scratch. YMMV.
Related
I am using selenium with cucumber (using JAVA, but not much relevant)
Let's say I have following scenarios:
Feature: Sample Feature
Scenario: do action A on website Given website is opened And
user put correct login and pass in fields And user press login
Then do action A
Scenario: do action A on website Given website is opened And
user put correct login and pass in fields And user press login
Then do action B
Now, there will be hundreds of scenarios, and website always require to log in into the website, so I assume for each test scenario I will have to repeat login steps (for example by BACKGROUND or before scenario hook)
I have been reading that this sort of tests should be autonomous, so there should be no sharing of instance of webdriver between scenarios
Say:
Feature: Some feature
Scenario: Log into website first
Steps...
Scenario: Do action A (while we are logged already
Steps...
Scenario Do action B (all the time in same browser instance we used in
login step and action A step
Steps...
But I found people saying its not correct way, but repeating login procedure everytime I want to perform some test scenario takes a lot of time during runing many scenarios and each needs to log in first. I was thinking about enabling possibility to access website without login for testing purpose, is there any recommended approach? Thank you.
Every scenario that requires a user to be logged in will need to have the user log in. This is part of the cost of running at the integration level. However log in should not be an expensive time consuming operation, you only have to fill in two fields and submit them. It should take < 100ms to process the login.
Now for unit testing this time is huge, but for an integration test, which by its nature involves a much bigger stack and usually simulated human interaction (otherwise why do you need your user to login) this time is a relatively small component of the overall scenario run time.
Because Cucumber works at the integration level it is best not to use it as a testing tool, rather it should be used as a tool to drive development. Instead of writing thousands of small assertions (like you might when unit testing) you need to write fewer larger scenarios i.e. each scenario needs to do more. As each scenario is doing more the need for each scenario to be completely independent of any other scenario increases (the more you do, the more likely you are to be side effects on other things that are done). Sharing sessions and trying to avoid resetting the db and session between each scenario turns out to be a false optimization that creates more problems than it solves.
Its perfectly fine for a scenario to do alot before you get to its when. For example imagine the following e-commerce scenario.
Scenario: Re-order favorite
Given I have a favorite order
When I view my orders
And I re-order my favorite order
Then I should be taken to the checkout
And my favourite items should be in the basket
Now clearly an awful lot of stuff needs to happen before I can re-order e.g.
I need to register
I need to make at least one previous order
I need to choose a favorite order
and of course there are lots of other things like
there need to be products to be ordered
All of this means that this scenario will take time to run, but thats OK because you are getting alot of functionality from it. (when I wrote something similar a long time ago, the scenario took 1-2 seconds to run). The login time for this sort of scenario is trivial compared to the time required to do the rest of the setup.
I know nothing about Selenium with cucumber (but i like cucumber :-)
I'm from Selenium for Python. There I can do the following things:
from selenium import webdriver
profile = webdriver.FirefoxProfile(your_path_to_local_firefox_profile)
# like C:/Users/<USERNAME>/AppData/Roaming/Mozilla/Firefox/Profiles/<PROFILE_FOLDER>
browser = webdriver.Firefox(profile)
So, now with "[WIN] + [R]" -> Run -> "firefox.exe -p" I can create an extra profile for Selenium to use it in the code above, so I can use Firefox as well start with the profile on a trial basis. ALSO If your website with login you want to automate, cookies & cache etc. supports, then it could be that you do not have to log in via the firefox profile every time, but that the Firefox starting each time automatically logs in because he stored the login data.
I do not know if that helps, but I wanted to tell you.
Basically, I need to update below screen shot details for every application generated or every build occurs in Installr app. I thoroughly checked API there is no method to help the above scenario.
I need to auto Provisioning the IOS application for each Build.
Now I am trying to accomplish that above task using Java, Jsoup web Scraping Technic . Please Let us know if the task is not possible to using above techs stack also suggest me any other JS to full fill the requirement.
I can see two options for you:
Option 1: Stay with your current techs stack...
Fire up the network tab in the developer toolbar of your favorite browser.
Play the scenario manually in your browser and carefully study the HTTP exchanges between your browser and the server.
Once you have understand the exchanges made, reproduce them with Jsoup in your Java code.
Option 2: Change your techs stack
I suggest you to try one the tools below:
Selenium
ui4j
Both handle Javascript and will facilitate the automation of your scenario.
They will automatically determine the appropriate exchanges to do.
We are developing a Wicket Application where users can log in and perform searches on a Lucene index. They can also modify their own, small index.
We have great test coverage for single-user scenarios. However, as the application is intended to be run on a server and have multiple, concurrent users, I would like to be able to set-up a test that covers this scenario (e.g. 1 application, 10 concurrent users).
I have some experience using jmeter, but I would prefer a WicketTester-style approach if possible.
Does anyone have expercience setting up such a test? Or good pointers?
We also use Wicket but concurrent users is not my main focus (no end-users). Sometimes I need to check cookie-behaviour, session-management etc. and then I use SAHI which also exists as open source IMO and as a demo. We use the Pro version also in other projects. From my perspective easy to learn and to handle.
_navigateTo("http://myapp/login.html");
// login as first user
...
// launch a new browser instance
var $instanceId = _launchNewBrowser("http://myapp/login.html");
_wait(5000);
// wait and select the new browser instance using the instanceId
_selectBrowser($instanceId);
// log in as second user
// send a chat message to first user
...
// Select the base window
_selectBrowser();
// view chat window and verify second user's chat message has arrived
...
Taken from documentation
I'm afraid it won't be possible to do what you need with WicketTester.
It starts one instance of the application. This is fine!
But it also acts like a browser, i.e. a single client.
I have used http://databene.org/contiperf for some perf tests (non-Wicket) before and I liked it. But if you try to use it with WicketTester then you either will have to have a separate WicketTester for each user or you will face synchronization issues in WicketTester itself.
I'd recommend you to use JMeter or Gatling. A user from the community made this integration: https://github.com/vanillasource/wicket-gatling. I haven't used it yet but I hope to try it soon.
I am new to Selenium IDE. As far as I know, when open Selenium IDE, you will notice that the red 'record macro' button is toggled. This means that selenium will attempt to record every action you make inside the browser. This is a problematic way of recording as we implicitly wait for actions to complete before moving on.
If I only let Selenium to record every actions without specifying extra actions, many test step will be failed with error message : Element not found. I was trying to add extra actions based on Selenium API, like waitForElementPresent, waitForSearch etc.
My question is: How do I know which extra action do I need to add for each web target? Any standard for it? Thanks!
I use webdriver but I am familiar with IDE and so far I know it depends on your application how you want to handle the tests. If your application uses ajax calls you might need to use some frequent waitForElementPresent or waitForSearch etc.. and Assertions also depend on the needs of your tests.
Now, the question is how do you know which extra step do you need to insert?
Ans. is you will know the necessity. Such as, if your test step depends on a previous ajax call to finish then you know there is a wait necessary and you know what to do. Not to mention, you can always insert extra steps and I am sure you already know that. And, there is no standard for using those. You adjust your tests depending on your necessity
you need to go through introduction to selenium ide or just think straight this way that if any action needs loading of page, you simple need to wait for element present and the perform click
click|target|
waitForElementPresent|target|
or if you need to store any value you can use
storeEval|target|value
also the variable name in the selenium ide is named followed by $variableName
enter can be performed as ${KEY_ENTER}
to verify any value we can use AssertValue or VerifyValue
the difference between assert and verify is that assert stops the execution of test case if the value is false whereas verify gives error and execute next statement.
these are few points to be noted in selenium ide.
hope this answer would help you!
You may want to try Implicit Wait addon for Selenium IDE. It will automatically call WaitForElementPresent before executing actions on that element (like clicks). This may save you some time.
Here is the link of Selenium API, all actions can be found here.
Although I've been programming for a few years I've only really dabbled in the web side of things, it's been more application based for computers up until now. I was wondering, in java for example, what library defined function or self defined function I would use to have a program launch a web browser to a certain site? Also as an extension to this how could I have it find a certain field in the website like a search box for instance (if it wasnt the current target of the cursor) and then populate it with a string and submit it to the server? (maybe this is a kind of find by ID scenario?!)
Also, is there a way to control whethere this is visible or not to the user. What I mean is, if I want to do something as a background task whilst the user carries on using the program, I will want the program to be submitting data to a webpage without the whole visual side of things that would interrupt the user?
This may be basic but like I say, I've never tried my hand at it so perhaps if someone could just provide some rough code outlines I'd really appreciate it.
Many thanks
I think Selenium might be what you are looking for.
Selenium allows you to start a Web browser, launch it to a certain website and interact with it. Also, there is a Java API (and a lot of other languages, by the way) allowing you to control the launched browser from a Java application.
There are some tweaking to do, but you can also launch Selenium in background, using a headless Web browser.
as i understand it you want to submit data to a server via the excisting webinterface?
in that case you need to find out how the URL for the request is build and then make a http-call using the corresponding URL
i advice reading this if it involves a POST submit