I wrote an HTTP request in JMeter which creates a Profile with a new Profile ID( which I am passing as a parameter in URL)
I want to generate a new profileID, in case if the given ProfileID is already existed.
How can I do this in JMeter?
currently test runs and passes with showing message that "Profile ID is already existed" as a result, in case of already existed ID.
Don't get Idea how to solve this issue .If I use "if controller", it will check pre-execution condition while I have a post-execution condition that the test runs and after getting this message "already existed" on page it should generate a new ID.
Any help would highly be appreciated.
You can do the following:
While Controller with condition: ${IdExisted} != "Profile ID is already existed"
HTTP Request generating random profile Id
Regular Expression Extractor with reference name IdExisted, regex like "Profile ID is already existed", default value NOT_FOUND
You can carry out "Profile ID is already existed" to User Defined Variables to DRY this test.
But I think, you really don't need While Controller and Regular Expression Extractor. Maybe, you can just make HTTP Request generate more random Id.
To generate random id you can use function:
Random if it should be an int, e.g. ${__Random(1, 100000000)}
RandomString if it should be a string, e.g. ${__RandomString(10)}
Related
url <- read_html('https://ngodarpan.gov.in/index.php/home/statewise_ngo_sof/27/35/1?')
valuation <- html_nodes(url,xpath='//*[(#id = "ngo_state_p")]')
valuation
class(valuation)
valuation1 <- html_text(valuation)
valuation1
the result of above code is empty string?is there any way out to get the exact value.
ngodarpan.gov.in/index.php/home/statewise_ngo/62/35/1 click on the name of first NGO AdityaNatyaAcademy,under that pop check the value for state for registration i.e ANDAMAN & NICOBAR ISLANDS
Your individual NGO data is coming in ajax requests in the background. Below is the javascript code that's fetching your data.
Function: function show_ngo_info(ngo_id) (in the same page...)
$.post("https://ngodarpan.gov.in/index.php/ajaxcontroller/show_ngo_info", {
id: ngo_id,
csrf_test_name:get_csrf_token()
}
It's using csrf token, which may complicate your automation a little bit. But, you should still be able to retrieve data with this. Let me know how it goes.
The data is being fetched on NGO link click in the background, and hence you are getting empty string when trying to read the data before that.
I'm writing some Selenium UI automation tests and I'm currently working on a section where multiple validation messages can appear depending on the response from source system. I have several different messages to trigger.
Every time the error message is shown on the UI it will sit in the following element but the text string changes each time depending on what the message is while the id and class remain the same:
<span id="lblErrorText" class="validationError">
"My error message will appear here"
</span>
In my page object class I am defining my fields before I use them in a method. So I have the following:
By errorMessage = By.xpath("//span[#class='validationError']");
I then use errorMessage in a method to return it as a boolean to enable me to assert against. As follows:
public boolean getInvalidRefNumberErrorMessage(){
return driver.findElements(errorMessage).contains("My error message will");
}
But every time I run my test I see that method getInvalidRefNumberErrorMessage is returning a FALSE.
I've tried using the id instead but no luck. I've never had to validate a dynamic message before so I'm a bit stuck here.
Seems your code has some wrong places if they are not copy/paste mistake.
Should use findElement, not findElements which return a List.
Should call getText() to return the message content as String, then call String.contains()
public boolean getInvalidRefNumberErrorMessage(){
return driver.findElement(errorMessage).getText()
.contains("My error message will");
}
I have my webpage opened using RFT. In that page, I have a link I want to click.
For that I am using
objMap.ClickTabLink(objMap.document_eBenefitsHome(), "Upload Documentation", "Upload Documentation");
The current page link name is "Upload Documentation"
I know that objMap.document_eBenefitsHome() takes it back to the initial page, what can I use in that place which uses the "current page opened" ?
Many thanks in advance.
There are some alternatives that could solve your problem:
Open the Test Object Map; select from the map the object that represents the document document_eBenefitsHome; modify the .url property using regular expression, so that the URLs of the two pages you cited in your question match the regex.
Find dinamically the document object using the find method. Once the page containing the link you want to click was fully loaded, try to use this code to find the document: find(atDescendant(".class", "Html.HtmlDocument"), false). The false boolean value allow the find method to search also among object that are not previously recorded.
I am currently trying to enhance the To-Do List tutorial from Play framework's website. I've added a login form, (and of course a User class acting as a model), and it works perfectly well. I also made a small "dashboard" in which the logged user is able to change his password and his email address. But when I submit the form, I get a "Datasource user is null ?" error (RuntimeException).
The whole problem came when I wanted to restrict the edition possibilities (I first used a whole User form, which is quite over the top (User do not need to edit their ID). So I made a small inner class in my Application file called UpdateUser which gathers the required informations, just as I did for the login system.
Searching this error gave me many results but people saw their problem fixed by uncommenting the ebean.default line in the conf file, which I already did.
Here is the method I used to update user's informations :
Firstly, I made a small class in my Application to hold the form (exactly like I did for the login thing).
Then I made a update function as found here in my user class :
public static String update(String id, User newuser) {
newuser.update(id);
return("Your profile has been updated");
}
which returns the String that will be in my flash and which is according to my compiler the problem function.
This function is called in my Application like this :
public static Result updateUser(String id)
{
Form<UpdateUser> filledForm = updateUserForm.bindFromRequest();
System.out.println("Updated User : "+filledForm.get().id);
if(filledForm.hasErrors())
{
flash("success","Error while updating");
}else{
User user = new User(filledForm.get().id, filledForm.get().email, User.find.byId(filledForm.get().id).name, User.find.byId(filledForm.get().id).surname, filledForm.get().password);
flash("success", User.update(id,user));
}
return redirect(routes.Application.dashboard());
}
I tracked the data in the Form and it is not null (I mean I can get everything from the form). But I wonder if I have to create another ebean or if it's my function which is wrong. I also wonder if it's not my User creation that fail. Or maybe I should take the updateUser function and put it in my inner UpdateUser class ?
I have to admit that I worked on that all of yesterday (and probably today too), and I can't find anything on the internet except the ebean.default thing.
------EDIT
I continued to search, so here's what I tried :
1) Getting the form result into an instance of UpdateUser in order to use it
2) Use this instance instead of getting the data from the form
But it failed too. What's really weird is that I've added a toString() method for User class, and calling it on the user I want to insert (as an update) gives me the full stuff. I think it must be a configuration problem, but I can't see it.
Another thing : when I come to the error page and when I try to come back to the application by modifying the URL, I am disconnected. Is it my ebean that closes himself ?
Last edit for the day, I'm getting tired of this. I tried to delay the action (i.e. making it happen after the user has logged out), the new data are correctly saved but I still get the error when calling the update function.
Alright, I finally found it, but totally by chance.
I just had to write this :
public static String update(String id, User user) {
user.update((Object)id);
return ("Your profile has been updated");
}
Because for some reason that I don't really understand, The id String needs to be cast to Object. The rest of the code was correct. But apparently, when using update() on this particular case (is it because my id is a String or because I get the informations from another class before using it as my Model), the parameter which is supposed to be a String (even in the documentation) HAS to be cast.
That's it.
I have a simple MVC-based JSP application. Something like:
*.jsp -> ControllerServlet -> *Command.java -> *Service.java -> *DAO.java -> Oracle db
A typical link in the application looks like this:
myapp/controller?cmd=ShowEditUser&userid=55
Which causes ShowEditUserCommand.java execute() method to run and will forward to editUser.jsp
In editUser.jsp, they fill in the fields, then click Save which posts to myapp/controller?cmd=ModifyUser which runs ModifyUserCommand.java execute() method which modifies the user data and forwards to viewUser.jsp.
Everything works fine.
The problem is, in ModifyUserCommand.execute() I'm checking to see if the username is unique. If they try to enter a username that already exists, I set an error value to true and errorMessage value to Already in use.
Then because of the error I forward to the original editUser.jsp (not viewUser.jsp) and the error is displayed above the form.
MY PROBLEM IS (finally! ;) -- when the user is returned to editUser.jsp with the error message displayed, the data they entered in the fields is all blanked out. How can I set it so whatever they entered in the fields is still in place?
Any suggestions or advice are greatly appreciated!
Rob
Simplest way would be to pass the form fields back to your editUser.jsp in your forward action in ModifyUserCommand.execute(). You can do that with individual parameters i.e.
editUser.jsp?field1=1&field2=2
Alternatively, you could pass data with other methods - i.e. encoded JSON.
You can then process your fields in your editUser.jsp via the page's request object and set your form field values accordingly.
There may be other ways to do this depending on what underlying framework (if any) you are using. But this is a basic way of approaching it.