I can click a button in Firefox - why not in Chrome? - google-chrome

I'm using Watir WebDriver with Chrome and Firefox.
With FF, I can click the following button:
#browser.button(:id => 'btnSubmit').when_present.click
With Chrome, I get the following message:
Selenium::WebDriver::Error::UnknownError: unknown error: Element is not clickable at point (730, 681). Other element would receive the click: <div class="blockUI blockOverlay" style="z-index: 1000; border: none; margin: 0px; padding: 0px; width: 100%; height: 100%; top: 0px; left: 0px; background-color: rgb(0, 0, 0); opacity: 0.38143215011627357; cursor: default; position: fixed;"></div>
If I place a breakpoint on the offending line, the next single step in debug mode works OK.
As an experiment, in case of timeout issues, I changed the code to:
#browser.button(:id => 'btnSubmit').when_present(100).click
This fails in run mode, with the same error.
If I search the entire page, I can't find the "other element" that would receive the click.
<div class="blockUI.............
Here are the divs before and after the button:
<div id="divSaveCancel" class="row">
<div class="six mobile-four columns">
<ul class="button-group even three-up">
<li>
<button id="cancelBtn" type="button" class="small alert button">
Cancel</button></li>
<li>
<button class="small button" id="btnSave" type="submit" name="command" value="btnSaveDraft"
onclick="beforeSubmit();">
Save Draft</button></li>
<li>
<button class="small success button" id="btnSubmit" type="submit" name="command"
onclick="beforeSubmit();" value="btnSubmit">
Save and Continue</button>
</li>
</ul>
</div>
<div class="six mobile-four columns" style="text-align: right;">
<span style="text-align: right; margin-right: 5%; vertical-align: middle; width: 100%;">
<button id="btnSendNotification2" class="small button" type="button">
Send Notification</button></span>
</div>
</div>

Instead of doing:
while (#browser.div(:class => 'blockUI blockOverlay').present?)
sleep(1)
end
#browser.button(:id => 'btnSubmit').click
You should be able to do:
#browser.div(:class => 'blockUI blockOverlay').wait_while_present
#browser.button(:id => 'btnSubmit').click

#JustinKo: I checked both.
Here is a comment from the developer:
It is a modal ‘Please Wait...’ popup that appears for a very short duration of time when the document is being loaded or when some time consuming activity is being performed. That code is dynamically injected by JQuery plug-in and removed soon after. That may be the reason why we can’t find it in the document source.
Remember that the following did not work:
#browser.button(:id => 'btnSubmit').when_present(100).click
But the following works:
sleep(1)
#browser.button(:id => 'btnSubmit').click
So the target element is always present.
The following does not work:
while !(#browser.button(:id => 'btnSubmit').visible?)
sleep(1)
end
#browser.button(:id => 'btnSubmit').click
So the target element is always visible.
The solution is to wait for the "other element" to disappear:
while (#browser.div(:class => 'blockUI blockOverlay').present?)
sleep(1)
end
#browser.button(:id => 'btnSubmit').click

Related

Moving an image in a Popup Modal not working, but in the main container

I'm working with a project in Blazor.
I'm using a component called "BlazorWheelZoom" (https://github.com/iso8859/BlazorWheelZoom)
This is my first page:
#page "/"
#page "/print"
#using Blazorise
#using LabelPrint.Shared
#using Linak.LabelPrint.Client.Shared.Components
<h3>Print</h3>
<div class="container-lg">
<div class="row">
<div class="d-flex justify-content-center">
<div style="border: thin solid green; width: 510px; height: 510px; padding: 5px;">
<WheelZoom Image="/Img/rotate0.png" width="500" height="500" />
</div>
</div>
.... and so on
For this HTML as you can see above, I get the following output:
The image refuses to move to the left, just as expected. If i zoom in a little bit I can move it a few pixels corresponding to the difference (the part of the image that you cannot see) and then it stops.
See the demo of the creator: https://blazorwheelzoom.azurewebsites.net
But when I add the exact same code to a popup Modal, I can keep moving it to the left.
I have the exact same HTML and CSS, so it must be something with the parent I guess. But I have tried to disable/enable stuff, but without luck. I just want the image to be prevented from moving "out of bounds" if you know what I mean.
This is the HTML in my Modal:
<Modal #ref="LabelPreview">
<ModalContent Centered="true" Size="ModalSize.Large">
<ModalHeader>
<ModalTitle>Show</ModalTitle>
<CloseButton />
</ModalHeader>
<nav class="navbar navbar-light bg-light">
<Button #onclick="() => RotateImage(true)">
<i class="fas fa-redo"></i>
</Button>
<Button #onclick="() => RotateImage(false)">
<i class="fas fa-undo"></i>
</Button>
</nav>
<ModalBody>
<div class="d-flex justify-content-center">
<div class="#($"{rotationClass} frame")">
<WheelZoom Image="#(rotate0)" width="500" height="500" />
</div>
</div>
</ModalBody>
<ModalFooter>
<Button Color="Color.Secondary" Clicked="#DownloadImage">Download</Button>
<Button Color="Color.Primary" Clicked="#HidePreviewModal">OK</Button>
</ModalFooter>
</ModalContent>
The Modal component I'm using is from Blazorise
This gotta be some CSS thing, but I'm about to give up. So hopefully some of you guys can help me.

Clear validation message when the form is submitted

I created a form that contains a textbox. If you try to submit the form without filling in the textbox, a validation message is displayed.
If the textbox is filled, I intend to clean all its content when submitting the form. My problem is that I can clean the textbox after submitting without the validation message appearing, however, when I switch to another Tab and then return to it, that validation message is displayed. How can I solve this?
PROBLEM
DEMO
html
<div class="container">
<div class="tab-slider--nav">
<ul class="tab-slider--tabs">
<li class="tab-slider--trigger" [class.active]="viewMode == 'tab1'" rel="tab1" (click)="viewMode ='tab1'">
Tab 1 - list</li>
<li class="tab-slider--trigger" [class.active]="viewMode == 'tab2'" rel="tab2" (click)="viewMode ='tab2'">
Tab 2 - Create</li>
</ul>
</div>
<div class="tab-slider--container" [ngSwitch]="viewMode">
<div id="tab1" class="tab-slider--body" *ngSwitchCase="'tab1'">
LIST
</div>
<div id="tab2" class="tab-slider--body" *ngSwitchCase="'tab2'">
<form (submit)="SaveGroup($event)" style="width: 100%; height: 92%;">
<dx-validation-group #CreateGroup>
<div style="width: 100%; height: 100%; overflow: auto;">
<div style="
display: flex;
align-items: center;
flex-direction: column;
width: 100%;
">
<span class="title1">Name</span>
<div class="mytextbox">
<dx-text-box [(ngModel)]="Name" [ngModelOptions]="{standalone: true}"
placeholder="Enter Name">
<dx-validator>
<dxi-validation-rule type="required" message="Name is required">
</dxi-validation-rule>
</dx-validator>
</dx-text-box>
</div>
</div>
</div>
<div style="padding-top: 10px;">
<dx-button class="customButtom" type="submit" id="button" text="Save"
[useSubmitBehavior]="true">
</dx-button>
</div>
</dx-validation-group>
</form>
</div>
</div>
</div>
.TS
SaveGroup(e) {
let self = this;
self.viewMode = 'tab1';
self.validationGroup1.instance.reset();
}
If you comment this line self.viewMode = 'tab1'; (do not change the tab after submitting) the textbox is successfully cleared. If you change tab and then return to the one with the textbox, the validation message is always displayed.
It seems that field is in "touched mode" because the value is stored in two way binding in Name.
I have tried this :
SaveGroup(e) {
const savedNameValue = this.Name;
this.validationGroup1.instance.reset();
this.Name = null;
this.viewMode = 'tab1';
}

How to Bind/change the below HTML button drop down lists using Angular Reactive forms

<div class="c-field">
<label [attr.for]="dropdownId"
class="c-field__label">{{label}}</label>
<div class="c-dropdown" [attr.id]="dropdownId"
aria-labelledby="dropdown-demo-no-error-dropdown-label"
aria-describedby="dropdown-demo-no-error-field-helper">
<button class="c-btn c-dropdown__toggle c-btn--dropdown"
type="button" [(ngModel)]="selectedValue"
data-toggle="dropdown" (click)="onDropdownValueChange($event)"
aria-haspopup="true"
aria-expanded="false"
aria-describedby="dropdown-demo-no-error-button"
[attr.id]="dropdownId">
<span class="c-dropdown__text">Dropdown</span>
</button>
<div class="c-dropdown__menu dropdown-menu"
aria-labelledby="dropdown-demo-no-error"
x-placement="bottom-start"
style="position: absolute; will-change: transform; top: 0px; left:
0px; transform: translate3d(0px, 40px, 0px);">
<hr>
<button class="c-dropdown__item " *ngFor="let item of dataSource"
type="button"
[attr.id]="dropdownId + item.id">{{item.text}}</button>
</div>
<div *ngIf="isFormSubmitted && dropdownFormControl.errors">
<span class="c-field__error" id="dropdown-demo-error-field-error">
{{ label }} {{ errorMessages.RequiredField }}</span>
</div>
<span class="c-field__helper" *ngIf="helperText"
id="dropdown-demo-no-error-field-helper">{{helperText}}</span>
</div>
</div>
Here the above HTML for drop down the binding. but when
I click on button click event drop-down event is not firing.
Could you please suggested me how to change event will work?
You can't bind using Angular Reactive Form as this is a html button and both Reactive Forms (via FormControlDirective directive) or by Template-driven Forms (via the ngModel directive) wont work. Both of these directives are designed to work with html input elements.
I don't think it would make much sense if they were html input elements of type button either. Since in that case the value attribute would determine the text on the button and would not change via user interactions.
I think your best bet is to handle the updating of the selectedValue value through click events on the 'drop down' list itself:
<div class="c-dropdown__menu dropdown-menu"
aria-labelledby="dropdown-demo-no-error"
x-placement="bottom-start"
style="position: absolute; will-change: transform; top: 0px; left:
0px; transform: translate3d(0px, 40px, 0px);">
<hr>
<button class="c-dropdown__item " *ngFor="let item of dataSource"
type="button"
[attr.id]="dropdownId + item.id" (click)="onDropdownValueChange(item)">{{item.text}}</button>
</div>

Bootstrap 3.3.7 collapse button issue(doesn't work)

I have the following code:
#foreach(var data in Model.test){
<div style="margin: 3% 0 3% 2%;">
<button type="button"
class="btn btn-warning"
style="display:block; width:40%;overflow-wrap:normal;white-space:normal;padding:.5%;"
data-toggle="collapse" data-target="##data.option">
#data.Name
</button>
<div id="#data.option" class="collapse" style="width:40%;float:right;white-space:normal; overflow:scroll;">
<br />
<div>
<a>
Title: #data.Name<br />
#foreach (var item in data.Documents)
{
<p>Related Document: #item.Name</p>
}
</a>
</div>
</div>
</div>
}
When I tried general example from bootstrap site it works fine.. but when I plug in the values etc I want it fails.. what am I missing? This is in a view of an MVC web app.
I changed the id to be an incremental counter.. so now it works. As pointed out I may have had a duplicate somewhere there.
There were spaces and special chars which was causing this issue. After removing them all it worked.

Textbox with Dropdown as Group Addon

I am trying to use the Dropdown as a Group Add-on in bootstrap:
<div class="col-md-5">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">#Html.DropDownListFor(m => m.SelectedCountryCode, new SelectList(Model.ListOfCountries, "PhoneCode", "PhoneCode"), "Select")</div>
#Html.TextBoxFor(m => Model.Value, new { #class = "form-control" })
</div>
</div>
</div>
This is the result I get:
Is there another way to do this so my styles of dropdown are same as the textbox?
I don't want the grey part around the dropdown.
Here is a JSFiddle:
https://jsfiddle.net/mdawood1991/yLygh0v4/
This is the best way to fix this. Style the dropdown with this:
background: transparent;
border: 0;
Then it'll look like this:
And when open:
You can use an input-group-btn dropdown:
<div class="input-group-btn">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"
aria-expanded="false">Select <span class="caret"></span></button>
<ul class="dropdown-menu" role="menu">
<li>0044</li>
<li>0033</li>
<li>001</li>
</ul>
</div><!-- /btn-group -->
Fiddle.
Or, you can remove the padding from the .input-group-addon:
.input-group-addon {
padding: 0 !important;
background: transparent;
}
Fiddle.
What about styling the select box?
select{
background-color: transparent;
}
It may be that I got your question wrong :)
The area then just vanishes on my phone. I'm using safari on iOS 8.
You can also override the background color for that class:
.input-group-addon {
background: white;
}
Or just change it in the existing CSS.