Summary: When a dialog window is opened, the dialog contains a form, yet the INPUT fields do not allow text entry. FireBug Console reports the following error when I press a key and the cursor is in the text field:
The 'charCode' property of a keydown event should not be used. The value is meaningless.
/lemonade_stand/start.php Line 0
I also see this error when the window opens:
Unknown pseudo-class or pseudo-element 'tabbable'.
/lemonade_stand/start.php Line 0
It seems that some over event is listening for a keypress. I found an article that suggested that I "remove the ui-dialog class from the div", yet even trying that didn't help.
Code samples:
Definition of Dialog Box
var $priceWindow = $("#setPriceWindow").dialog({
autoOpen: false,
height: 306,
modal: true,
width: 380,
buttons: {
"Save": function(){
$.get('php/saveQA.php',
{
'cup': $("#pCup").val(),
'lemons': $("#pLemons").val(),
'sugar': $("#pSugar").val(),
'ice': $("#pIce").val(),
});
$(this).dialog('close');
},
Cancel: function(){
$(this).dialog('close');
}
}
});
Event to open Dialog box
$("#setPrice").click(function(e){
e.preventDefault();
$priceWindow.dialog('open');
});
PHP/HTML content of dialog
<div id="setPriceWindow" class="priceWin" title="Set Price and Quality">
<form>
<ul>
<li><label>Price Per Cup</label><span><span><input type="text" size="3" id="pCup" tabid="1" value="<?php echo $_SESSION['qa']['cup']; ?>" /><p>Cents</p></span></span></li>
<li><label>Lemons Per Pitcher</label><span><span><input type="text" size="3" id="pLemons" tabid="2" value="<?php echo $_SESSION['qa']['lemons']; ?>" /><p>Lemons</p></span></span></li>
<li><label>Sugar Per Pitcher</label><span><span><input type="text" size="3" id="pSugar" tabid="3" value="<?php echo $_SESSION['qa']['sugar']; ?>" /><p>Cups</p></span></span></li>
<li><label>Ice Per Cup</label><span><span><input type="text" size="3" id="pIce" tabid="4" value="<?php echo $_SESSION['qa']['ice']; ?>" /><p>Cubes</p></span></span></li>
</ul>
</form>
</div>
Full project can be seen here: http://yrmailfrom.me/games/lemonade_stand/start.php
The problem is in your game.js script.
In
$("#setPrice").click(function(e){
e.preventDefault(); **// THIS LINE IS CAUSING THE TROUBLE**
$priceWindow.dialog('open');
});
Also in lemonade_game.css try removing the zIndex from this block
div#setPriceWindow ul li span {
background: none repeat scroll 0 0 #F9F9F9;
border-left: 1px solid #CCCCCC;
border-right: 1px solid #BBBBBB;
margin: 0;
padding: 3px 0;
}
Related
<div class="form-group m-l-4">
<label class="" for="">Share It :</label>
<p id="postcodep<?php echo isset($campaign['post_id']) ? $campaign['post_id'] : 0 ?>" style=" word-wrap: break-word; margin: 0px;
border: 1px solid #1083d4;
padding: 5px;
}">Please Generate Link</p>
</div>
<!--<button ng-click="getCode('<?php echo isset($campaign['post_id']) ? $campaign['post_id'] : 0 ?>', <?php echo isset($campaign['campaign_id']) ? $campaign['campaign_id'] : 0 ?>)" class="btn btn-default m-l-2 waves-effect waves-light"><span class="fa "></span>GET</button>-->
<button ng-click="getCode('<?php echo isset($campaign['post_id']) ? $campaign['post_id'] : 0 ?>', <?php echo isset($campaign['campaign_id']) ? $campaign['campaign_id'] : 0 ?>)" class="btn btn-info waves-effect waves-light m-b-5 btn-xs"><span class="fa fa-plus " ></span> GENERATE LINK </button>
I want the link generated, copied to clipboard
as soon as people click on generate link. Can anyone help me I am not to familiar with angular?
I don't know how this is working in Angular, but in pure JavaScript it can be something like:
<button id="get-link" data-link="<?= getCode() ?>">GET LINK</button>
document.getElementById('get-link').addEventListener('click', function () {
var temp = document.createElement('textarea');
temp.value = this.getAttribute('data-link');
document.body.appendChild(temp);
temp.select();
document.execCommand('copy');
document.body.removeChild(temp);
});
I'm using WebdriverIO to test some basic functionality on an Ionic (+ Angular) application. The framework setup works all right, but I can't find a way to click on certain HTML elements. For instance, this is some HTML sample:
<div class="tabbar show-tabbar" role="tablist" style="top: 166px; display: flex;">
<a class="tab-button has-title has-title-only" href="#" role="tab" id="tab-t0-0" aria-controls="tabpanel-t0-0"
aria-selected="true">
<span class="tab-button-text">Blah</span>
<div class="button-effect"></div>
</a>
<a class="tab-button has-title has-title-only" href="#" role="tab" id="tab-t0-1" aria-controls="tabpanel-t0-1"
aria-selected="false">
<span class="tab-button-text">Foo</span>
<div class="button-effect"
style="transform: translate3d(83px, -103px, 0px) scale(1); height: 240px; width: 240px; opacity: 0; transition: transform 395ms ease 0s, opacity 277ms ease 118ms;"></div>
</a>
<a class="tab-button has-title has-title-only" href="#" role="tab" id="tab-t0-2" aria-controls="tabpanel-t0-2"
aria-selected="false">
<span class="tab-button-text">Bar</span>
<div class="button-effect"
style="transform: translate3d(3px, -99px, 0px) scale(1); height: 240px; width: 240px; opacity: 0; transition: transform 395ms ease 0s, opacity 277ms ease 118ms;"></div>
</a>
<div class="tab-highlight animate" style="transform: translate3d(570px, 0px, 0px) scaleX(285);"></div>
</div>
And this is a super-simple test case that I'm doing to test the functionality:
import { expect } from "chai";
describe("Some Test", () => {
const logingUrl: string = "url0";
const appUrl: string = "url1";
it("Some Test Again", () => {
browser.url(logingUrl);
browser.url(appUrl);
const tab = $("#tab-t0-2");
tab.click();
expect(tab.getAttribute("aria-selected")).to.equal("true");
});
});
..but every time I run it, I get some weird error message that the element is no clickable at some point. Any clues?
[0-0] element click intercepted in "Some Test Again"
element click intercepted: Element <a class="tab-button has-title has-title-only" href="#" role="tab" id="tab-t0-2" aria-controls="tabpanel-t0-2" aria-selected="false">...</a> is not clickable at point (666, 170). Other element would receive the click: <ion-backdrop disable-activated="" role="presentation" tappable="" class="backdrop-no-tappable" style="opacity: 0.5;"></ion-backdrop>
(Session info: headless chrome=75.0.3770.100)
This is one of those classic Angular/Ionic backdrop gotcha's.
Let's start with the error message: element #tab-t0-2 is not clickable at point (coordinates), another element would receive the click: ion-backdrop.
This tells us that your targeted element cannot be clicked as the ion-backdrop tag is rendered on top of it. The ion-backdrop component is a short animation (usually used for modals), in this case, the semi dimming of the background (opacity: 0.5).
✖ Solution 1: Easy way to counter it? Explicitly expect for it to disappear, then click the targeted element.
it("Some Test Again", () => {
browser.url(logingUrl);
browser.url(appUrl);
// Explicitly wait for the backdrop animation to disappear:
const backdrop = $('.backdrop-no-tappable');
backdrop.waitForExist(5000, true, 'Backdrop still present');
const tab = $("#tab-t0-2");
tab.click();
expect(tab.getAttribute("aria-selected")).to.equal("true");
});
✖ Solution 2: Another thing you can try is only click on the tab element, once it is fully visible and intractable in the DOM (this is kind of a best-practice):
const tab = $("#tab-t0-2");
tab.waitForDisplayed(5000);
// For 'wdio-v4' users:
// tab.waitForVisible(5000);
tab.click();
expect(tab.getAttribute("aria-selected")).to.equal("true");
I am trying to click a button which is displayed/visible/present.
When doing it manually, user was able to click the button.
If the test was executed, you will notice that it is trying to click the button, but nothing is happening.
I also tried to put a very long wait and tried to click it manually during automation.
But, when clicking it, nothing also happens.
I cannot share the site since it is in a proxy.
This is the HTML of the button and it looks normal:
<a class="x-btn x-unselectable x-box-item x-toolbar-item x-btn-default-small" style="min-width: 75px; right: auto; left: 328px; top: 0px; margin: 0px;" hidefocus="on" unselectable="on" role="button" aria-hidden="false" aria-disabled="false" id="button-1011" tabindex="-1" data-componentid="button-1011">
<span id="button-1011-btnWrap" data-ref="btnWrap" role="presentation" unselectable="on" style="" class="x-btn-wrap x-btn-wrap-default-small ">
<span id="button-1011-btnEl" data-ref="btnEl" role="presentation" unselectable="on" style="" class="x-btn-button x-btn-button-default-small x-btn-text x-btn-button-center ">
<span id="button-1011-btnIconEl" data-ref="btnIconEl" role="presentation" unselectable="on" class="x-btn-icon-el x-btn-icon-el-default-small " style=""></span>
<span id="button-1011-btnInnerEl" data-ref="btnInnerEl" unselectable="on" class="x-btn-inner x-btn-inner-default-small">Save</span>
</span>
</span>
</a>
Code:
global.elmCBSave = element.all(by.cssContainingText('span', 'Save')).last();
it('should click the Save button.', function() {
global.elmCBSave.click();
});
I also tried using browser.executeSrcipt, this is working when executed thru console:
browser.executeScript('$(".x-btn-inner.x-btn-inner-default-small:eq(3)").click()')
There are a few things you can try.
Be sure to pass done into your callback and handle the returned promise from the click event
it('should click the Save button.', function(done) {
global.elmCBSave.click().then(function(){
done();
});
});
Also, I tend to put an expected condition to wait for element to be clickable: http://www.protractortest.org/#/api?view=ProtractorExpectedConditions.prototype.elementToBeClickable
var EC = protractor.ExpectedConditions;
// Waits for the element with id 'abc' to be clickable.
it('should click the Save button.', function(done) {
browser.wait(EC.elementToBeClickable($('#abc')), 5000).then(function(){
global.elmCBSave.click().then(function(){
done();
});
});
});
I want the browse button class same as Upload button: className='button-normal', what should i do
<form name="uploadForm">
<input name='uploadFile' id='uploadFile' type='file' style={{marginTop: '1%'}} onChange={this.check}/>
<br/>
<input type="button" value="Upload" style={{marginTop: '1%'}} className='button-normal' onClick={this.upload}/>
</form>
I did it by using <label htmlFor=[fileInputID] ....> to pretend and control Browse Button, hid the real Browse Button, and added a new disabled input to show the uploaded file name.
However, though I made the label looks like button, it's still not quite like a button, I hope the type of input is "button" but can still work the same as htmlFor, grateful if you have any idea to share.
check: function() {
document.getElementById("name").placeholder = document.getElementById("uploadFile").files[0].name;
},
///
<form>
<input name='uploadFile' id='uploadFile' type='file' style={{marginTop: '8px', fontSize:'17px', float: 'left'}} onChange={this.check} display= 'none' />
<label className='button-normal' style={{margin: '5px 5px 5px 5px', float: 'left'}} htmlFor='uploadFile'>Browse</label>
<input id="name" placeholder="No file selected" style={{fontSize: '17px', marginTop:'7px'}} disabled="disabled"/>
<input type="button" value="Upload" styles={{marginTop: '1%', float: 'left'}} className='button-normal' onClick=={this.upload}/>
</form>
I've been trying to resolve an issue for some time with connectToSortable and nested lists. I've created an example at jsfiddle that shows the basic code:
http://jsfiddle.net/ZYSYM/
What I would like to achieve is the ability for a user to drag a "New Item" from the right list into the sub items list. However, the issue is that it adds the item to both the sub and parent lists.
I've read that perhaps the Greedy option may resolve this, however I'm not sure if it's working correctly or I've misinterpreted how it's meant to work. I've googled and searched around but could not find anyone with the exact same issue.
I've also performed some debugging and the greedy option fires the line parentInstance._out.call(parentInstance, event); in jquery-ui, which I think is for this purpose, but it doesn't seem to have any affect.
I'm not an expert in jQuery so any help is greatly appreciated. Perhaps I've missed something simple or there's a better way of doing this?
Thanks and please let me know if you require any further information.
This is little trickier than simple cases:
The Html:
<div style="float: left;">
<ul id="list_1">
<li>Existing 1</li>
<li>Existing 2</li>
<li>
<ul id = "list_2">
<li><dl> <dt>Existing Sub 1</dt></dl></li>
<li>Existing Sub 2</li>
<li>Existing Sub 3</li>
<li>Existing Sub 4</li>
</ul>
</li>
<li>Existing 3</li>
<li>Existing 4</li>
</ul>
</div>
<div style="float: right; margin-top: 30px;">
<ul id="from_list">
<li class="new_item">New Item 1</li>
<li class="new_item">New Item 2</li>
<li class="new_item">New Item 3</li>
<li class="new_item">New Item 4</li>
</ul>
</div>
The CSS:
#list_1 .dropzone {
background-color: #FFFFFF;
border-bottom: 4px solid #FFFFFF;
height: 6px;
}
The Javascript:
var selector = '#list_1, #list_2';
$('#list_1 li').prepend('<div class="dropzone"></div>');
$('#list_1 li, #from_list li').draggable({
opacity: .8,
handle: ' > dl',
addClasses: false,
helper: 'clone',
zIndex: 100 }
);
$('#list_1 .dropzone').droppable({
accept: '#from_list li',
tolerance: 'pointer',
drop: function(e, ui) {
var li = $(this).parent();
var child = !$(this).hasClass('dropzone');
//If this is our first child, we'll need a ul to drop into.
if (child && li.children('ul').length == 0) {
li.append('<ul/>');
}
//ui.draggable is our reference to the item that's been dragged.
if (child) {
li.children('ul').append(ui.draggable);
}
else {
li.before(ui.draggable);
}
//reset our background colours.
li.find('dl,.dropzone').css({ backgroundColor: '', borderColor: '' });
},
over: function() {
$(this).filter('dl').css({ backgroundColor: '#ccc' });
$(this).filter('.dropzone').css({ borderColor: '#aaa' });
},
out: function() {
$(this).filter('dl').css({ backgroundColor: '' });
$(this).filter('.dropzone').css({ borderColor: '' });
}
});
You can see the result here:
http://jsfiddle.net/F3nck/
Credit due:
I found the solution and adapted to your example from:
http://boagworld.com/technology/creating-a-draggable-sitemap-with-jquery/