Click a html button in JMeter - html

I need to click an Add button.I have traversed to the page having the Button,as verified from Response data in View Results Tree.
I tried making a get request (post button click URL)but that didn't work.
Below is the HTML of the Button
<button
class="bigbutton ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
onclick="var win = this.ownerDocument.defaultView || this.ownerDocument.parentWindow; if (win == window) { window.location.href='?x=KOGI5TeEN-U*JE6roI7oZMd-OfKSr5oQnRTh7tHdN*Bh66LwE2vEHDjxo9WFuOf7Ti2zcBh-IaE'; } ;return false"
style="float: right;"
role="button"
aria-disabled="false">
<span class="ui-button-text"> Add </span>

You need to record the requests to see exactly what kind of requests are generated by your application.
Follow this tutorial to understand how to go about it.
http://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.pdf

Related

How to select an element from drop-down menu using <span>

I tried the following code below to click drop down:
driver.FindElement(By.XPath("//div[#id='content']/div/app-appdashboard/div[3]/div/div/div/div/button")).Click();
And I tried the following code to click on one of options from drop down:
driver.FindElement(By.XPath("//div[#id='cdk-overlay-0']/div/div/button[16]/span")).Click();
<button _ngcontent-jco-c9="" aria-haspopup="true" class="btn btn-state dropdown-toggle" mat-button="" ng-reflect-menu="[object Object]">
<span _ngcontent-jco-c9="" class="ng-star-inserted"> Update Overall App Status </span></button>
<button _ngcontent-jco-c9="" aria-label="option row button." class="menu-button mat-menu-item ng-star-inserted" mat-menu-item="" role="button" tabindex="0" ng-reflect-role="button" name="PM Supervisor Approved" title="PM Supervisor Approved" aria-disabled="false"><span _ngcontent-jco-c9="">PM Supervisor Approved</span><div class="mat-menu-ripple mat-ripple" matripple="" ng-reflect-disabled="false" ng-reflect-trigger="[object HTMLButtonElement]"></div></button>
Try this:
WebDriverWait wait=new WebDriverWait(driver, 20);
driver.FindElement(By.className("ng-star-inserted")).click();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(".//button[#name='PM Supervisor Approved']/span")));
driver.FindElement(By.xpath(".//button[#name='PM Supervisor Approved']/span")).click();

Button no longer functions Cookie Policy nav Window using Bootstrap 4.3.1 in ASP.NET Core MVC site

After intergrating Bootstrap 4 to my ASP MVC Core web project and changing some HTML code to a Cookie Policy window. I noticed the accept button no longer functions. The button is there and you can click on it but it dosen't respond.
Besides changing some of the HTML for the cosmetic appearance the only other change made was the removal of a div tag which defined a container class for the text content. The JQuery code listed remains unchanged.
The function is called by a tag located in the _Layout.cshtml file within the Visual Studio project. It was functioning before the change were made to the code.
Any positive insight would be helpful. Especially if there is something that I have missed or have out of alignment.
using Microsoft.AspNetCore.Http.Features
#{
var consentFeature = Context.Features.Get<ITrackingConsentFeature>();
var showBanner = !consentFeature?.CanTrack ?? false;
var cookieString = consentFeature?.CreateConsentCookie();
}
#if (showBanner)
{
<nav id="cookieConsent" class="navbar navbar-light fixed-bottom float-sm-left"
style="background-color:transparent" role="alert">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#cookieConsent .navbar-collapse">
<span class="sr-only">Toggle cookie consent banner</span>
<span class="navbar-toggler-icon"></span>
</button>
<span class="navbar-brand"><span class="text-info" aria-hidden="false"></span></span>
<div class="collapse navbar-collapse" style="background-color:rgba(49, 67, 179, 0.80); color:lightgoldenrodyellow">
<div class="container-fluid">
<h4><strong>COOKIE AND PRIVACY POLICY </strong></h4>
<p class="navbar-text" style="color:yellow">
This web site uses cookies and other technologgy for features and functions to
be viewed and operate normaly. You can acknowledge the site uses these features
by clicking the "Accept" button to the right of this message window. To view the
sites "Cookie and Privacy" policy page, click on the "Cookie and Privacy
Information" button.
</p>
<p class="navbar-text" style="color:whitesmoke">
NOTE: Clicking on the "Accpt" button only acknowledges you have read this
this message and is not a condition for access to this site.
</p>
</div>
<div class="nav-container float-right">
<a asp-controller="Home" asp-action="Privacy" class="btn btn-info navbar-btn">Cookie and Privacy Information</a>
<button type="button" class="btn btn-light navbar-btn" data-cookie-string="#cookieString">Accept</button>
</div>
</div>
</nav>
<script>
(function () {
document.querySelector("#cookieConsent button[data-cookie-string]").addEventListener("click", function (el) {
document.cookie = el.target.dataset.cookieString;
document.querySelector("#cookieConsent").classList.add("hidden");
}, false);
})();
</script>
}
It seems that adding hidden class is failed . If you want to hide the cookieConsent nav after clicking accept button , you could try the following two approaches :
add some css for the class "hidden" in the path wwwroot/css/site.css , the JQuery code listed remains unchanged.
.hidden {
display: none;
}
change the JQuery like below :
document.querySelector("#cookieConsent").setAttribute("hidden","true");

the <a> element with empty href in ng-template is not calling the javascript function

I have this template
<ng-template #thumbnailTemplate let-context="thumbnailContext">
<div id="{{context.divId}}">
<button type="button" data-toggle="modal" (click)="showEnlargeImage(context)">
<img id="{{context.imgId}}" src="{{context.imgSrc}}"/> <!-- this will have width, height=80-->
</button>
<a *ngIf="this.isEditing" href="#" id="{{context.closeId}}" onClick="deleteThumbnailfromContainer(context)"></a>
</div>
</ng-template>
The <a> is shown dynamically depending on the value of isEditing. This part works fine. On clicking <a>, I expect that deleteThumbnailfromContainer gets called and the page doesn't redirect because deleteThumbnailfromContainer returns false. But the page gets refreshed. I also think that deleteThumbnailfromContainer is not getting called because deleteThumbnailfromContainer has an alert which doesn't pop up.
deleteThumbnailfromContainer(thumbnailContext:ThumbnailContext){
console.log("delete thumbnail clicked ");
let index = this.thumbnailContainerRef.indexOf(thumbnailContext.viewRefId);
console.log("deleting index "+index);
this.thumbnailContainerRef.remove(index);
alert();
return false;
}
The generated html looks like follows (looks alright to me).
<a _ngcontent-c9="" href="#" onclick="deleteThumbnailfromContainer(context)" id="close-button-1"></a>
I can't figure out why the code isn't working correctly here.
I think you should try this out.
<a *ngIf="this.isEditing" href="javascript:void(0)"
(click)="deleteThumbnailfromContainer(context)" id="close-button-1"></a>

Clicking on submenu, in a sidebar, go to a url with Material Design using Angular 4

I am working on a book collection program and I have a static sidebar which will have options and when you click on some of the options it sends you to a url.
I can't get the going to url part to work.
So I just have a sidenav, then a menu item called Store and then a submenu with an item called Amazon.
There may be typos, as I typed this as the code is on a different computer. Basically, how do I get where a submenu will send me to a url? I can do it from the menu item.
<md-sidenav #sidenav mode="side" opened="true" class="app-sidenav">
<md-nav-list>
<button md-list-item>Book Choices</button>
<button md-button>
<span md-list-item
[mdMenuTriggerFor]="amazon">Stores</span></button>
</md-nav-list>
</md-sidenav>
<md-menu #amazon>
<button md-button>
<span md-menu-item>
<span (click)="'http://amazon.com'">Amazon</span>
</span>
</button>
</md-menu>
You cannot navigate to a url using this expression (click)="'http://amazon.com'". You need to use window.location.href or window.open method. Here is how you can do that:
<md-menu #amazon>
<button md-button>
<span md-menu-item>
<span (click)="gotoUrl('http://www.amazon.com')">Amazon</span>
</span>
</button>
</md-menu>
in your typescript code, define the gotoUrl() method:
gotoUrl(url:string){
window.location.href=url;
}
if you want to open the url in a new tab in the browser, then use this code:
gotoUrl(url:string){
window.open(url, "_blank");
}
So while you can use (click) events in angular, if all you need to do is navigate to another url you can always just use good old html and an anchor link. If that's all your looking for keep it simple
<md-menu #amazon>
<button md-button>
<a md-menu-item href="http://amazon.com">
Amazon
</a>
</button>
</md-menu>
If you still want to use a click you can, and the answer below was correct it just had a typo
So add a method in your component like:
goToUrl(url: string) {
window.open(url);
}
And then in your view
<md-menu #amazon>
<button md-button>
<span md-menu-item (click)="goToUrl('http://amazon.com')">
Amazon
</span>
</button>
</md-menu>
this thing (click)="'http://amazon.com'" does nothing at all since you just passed a string.
have you tried (click)="window.open('http://amazon.com', '_blank')"?
or create a function that does the window.open(parameter)
openlink(url: string)
{
window.open(string, "_blank");
}
// HTML attribute
(click)="openlink('http://amazon.com')"

VBA - Click on a web page element with no id only class name

<div class="rightToolbarButtons">
<!--ko template: 'rightSearchDialogToolbarButtons' -->
<button class="main ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button" data-bind="jqueryui: {widget: 'button',options: {label: DWResources.WebClient.SearchText}},command: commands.searchCommand, attr: { title: DW.Utils.format(DWResources.WebClient.SearchDialog_SearchButtonTooltip, $data.fileCabinetName()) }" role="button" aria-disabled="false" title="Search in file cabinet INVOICE (Enter)"><span class="ui-button-text">Search</span> </button>
Please see the above HTML extract i am trying to click on a "search button".
i have no difficulty with clicking on buttons with ID but i am having difficulty with tag name and unsure which tag and name i should be using.
Any help would be much appreciated.
thanks in advance
Assuming no other search buttons you can use a CSS selector of
button[title*='Search']
Which is button tag with attribute title containing string 'search'.
The "*" indicates contains and "[]" attribute.
On your HTML:
VBA:
You apply the css selector via the .selector method of document.
.document.querySelector("button[title*='Search']").Click