Use Firebug command line to force click - command-line

I'm trying to use Firebug's command line to force a click event. This is as far as I've got and it's not very far.
document.getElementsByClassName('this_button').click();
Is is it possible to do what I want?
Thank you!

I wonder why no one provided a solution so far.
What you are searching for is this:
function simulateClick(element) {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
element.dispatchEvent(evt);
}
For more info see document.createEvent.
I didn't try it in other browsers, but at least it work for me in Firefox 18.0.1.

Related

TinyMce attribute invalid_elements does not prevent from indicated tags to be used or pasted, why is this happening?

I've been trying to use the invalid_elements property inside the window.tinymce.init object but to no avail, invalid elements and valid_elements (i.e. , , etc) keeps apearing if i paste something or if i select the bold option for instance. I also tried the paste_word_valid_elements: 'b,strong,i,em,h1,h2', property, without any positive results.
Also, in this site https://www.tiny.cloud/docs/demo/valid-elements/ you can try the properties i mentioned above and they still not work... why is that??
is this ment to be this way, is it a bug or am i missing something while coding it.
this is the object i'm passing to the init method:
selector: `#${(target as HTMLDivElement).id}`,
plugins: "paste",
inline: true, // does not work in mobile
forced_root_block: true,
force_br_newlines: false,
force_p_newlines: false,
invalid_elements : 'strong,em',
paste_merge_formats: true,
paste_preprocess: (plugin: any, args: any) => {
console.log("que trae",args.content);
console.log(">>>>>>>>", args.content.split('</p>'));
},
paste_word_valid_elements: 'b,strong,i,em,h1,h2',
}```

QLineEdit: Change clearButton

When I set clearButtonEnabled= true, clearButton looks blurry. Is there any way to change the size of clearButton or to customize it with another icon?
For anyone interested, I found this workaround:
QHBoxLayout *pSearchLayout = new QHBoxLayout();
pSearchLayout->addStretch();
pSearchLayout->addWidget(ui->pushButton);
pSearchLayout->setSpacing(0);
pSearchLayout->setContentsMargins(0, 0, 0, 0);
ui->lineEditSearch->setLayout(pSearchLayout);

jqGrid: Search form changed to be flat?

This is a subject based on "jqGrid - Change filter/search pop up form - to be flat on page - not a dialog" .
I've made the search form to be flat based on the subject , but right now I want not to show always on page , I want to show it only when the user press Search button from the jqGrid.
Can anyone give me an hint or solution how to do that, please?
#Oleg can you help me with that , please?
Thanks
Th solution could be very close to the old one. You can use the following options of the searching dialog:
overlay: 0,
drag: false,
beforeShowSearch: function ($form) {
var $searchDialog = $form.closest(".ui-jqdialog"),
$gbox = $(this).closest(".ui-jqgrid");
$searchDialog.insertBefore($gbox);
$searchDialog.css({
position: "relative",
zIndex: "auto",
float: "left"
})
$gbox.css({clear:"left"});
}
Other options (like closeOnEscape: true, closeAfterSearch: true, closeAfterReset: true, searchOnEnter: true, searchOperators: true and other) can be chosen depend on your preferences.
The demo displays the searching dialog like
If you prefer to use Bootstrap CSS instead of jQuery UI CSS then one should add some additional lines:
overlay: 0,
drag: false,
beforeShowSearch: function ($form) {
var $searchDialog = $form.closest(".ui-jqdialog"),
$gbox = $(this).closest(".ui-jqgrid");
$searchDialog.insertBefore($gbox);
$searchDialog.css({
position: "relative",
zIndex: "auto",
padding: 0,
float: "left"
});
$searchDialog.children(".modal-dialog").css({
marginTop: 0,
marginBottom: 0
});
$searchDialog.find(".modal-content").css({
boxShadow: "none"
});
$gbox.css({clear:"left"});
}
See the demo which displays:

Open new browser tabs without focus using CoffeeScript

How can I open new browser tabs without focus on them?
(Like clicking on the middle button on a mouse.)
Code:
$("html").on "click", ->
window.open('http://google.com')
$(document).focus()
And I want to still be on the current site.
This answer details what seems to be a legitimate way to open a tab in the background. Converting the answer to CoffeeScript, I get:
openNewBackgroundTab = ->
a = document.createElement("a")
a.href = "http://www.google.com/"
evt = document.createEvent("MouseEvents")
#the tenth parameter of initMouseEvent sets ctrl key
evt.initMouseEvent "click", true, true, window, 0, 0, 0, 0, 0, true, false, false, false, 0, null
a.dispatchEvent evt
return

casperjs + modal popup

i'm wondering why cannot get casperjs to recognize the modal popup:
var casper = require('casper').create();
casper.start('http://www.zulutrade.com/trader/140682?Lang=en');
casper.waitForSelector("form[name=aspnetForm] button#main_BtnFollow",
function success() {
this.test.assertExists("form[name=aspnetForm] button#main_BtnFollow");
this.click("form[name=aspnetForm] button#main_BtnFollow");
},
function fail() {
this.test.assertExists("form[name=aspnetForm] button#main_BtnFollow");
});
casper.waitForPopup(/popup\.html$/, function() {
this.test.assertEquals(this.popups.length, 1);
});
casper.run(function() {this.test.renderResults(true);});
running the above gives me timeout in the waitForPopup part..
How to make this work and how to use casper.withPopup properly with the popup?
ah, are you using Resurrectio? in my experience, you need to tweak whatever script they generate. i mostly only use it for element names.
i'm only seeing asserts in your script. i think you need to tell casper to click on something before you see your modal. something like this maybe?
casper.then(function() {
this.clickLabel('.Follow', 'a');
});
casper.waitForSelector("#modal_popup", function() {
this.echo('see the modal!');
this.capture('screenshotofmodal.png', { top: 0, left:0, width:1000, height: 4000});
});
PS
using capture() is super helpful in troubleshooting your scripts. i have them as sort of like, breakpoints where i can easily see what's going on if a test that i know should be passing is failing.
I've found myself implementing crude timeouts to get casper to play nicely with modal interactions:
casper.start(uri).then(function() {
var slideshow = 'a.photo_gallery_icon_modal_launch';
casper.wait(2000, function(){
casper.thenEvaluate(function(sel) {
$elem = jQuery(sel).first();
$elem.click();
}, slideshow)
}).wait(1000, function(){
// wait a sec for modal to show up before taking pic
casper.capture('foo.png', {
top: 0,
left: 0,
width: 1280,
height: 1024
})
})
});
There is also waitForSelector but I have not had as much success with it, because the contents of my modal are also asynchronous making the usage of wait or even waitForUrl more appropriate.
http://docs.casperjs.org/en/latest/modules/casper.html#waitforselector