Stackoverflow wmd load on click event - stack-overflow

I'm having a problem using the wmd re-engineer script.
The problem is the div where the wmd-container sits has display:none. This causes the following errors to be outputed constantly:
Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMNSHTMLTextAreaElement.selectionStart]
[Break On This Error] if (inputArea.selectionStart || inputArea.selectionStart === 0) {
If I add display:none on the textarea the problem goes away. But when I apply display:block on the elements; wmd buttons do not appear.
I am trying to figure out a way on how I can create an instance of this when the button is clicked.
Has anyone done this? I've had no luck =(

Related

Capybara with Selenium: Can't click on hidden element

I have a situation in my view where a clickable icon is only visible when it's containing div is hovered over (using Knockout JS, SCSS) . Something like this:
HTML
<div id="button_div">
<i id="icon" data-bind="click: dosomething"></i>
</div>
SCSS
i {
display: none;
}
#button_div:hover {
i {
display: block;
}
}
Everything works fine on the page, but I can't seem to figure out how to click the element in Capybara. I've tried adding the :visible symbol to the method, but with no luck:
find('#icon', visible: false).click
This gives me the a "Selenium::WebDriver::Error::ElementNotVisibleError" error.
Using:
Capybara.ignore_hidden_elements = false
Gives me the exact same error
I've also tried using a Selenium Action such as:
button_div_element = find('#button_div').native
button_element = find('#button', visible: false).native
page.driver.browser.action.move_to(button_div_element).click(button_element).perform
While this doesn't throw an error, it also doesn't click the button.
Does anyone have any idea what I might be doing wrong?
Capybara is designed to emulate a user so you can't click on a non-visible element because a user couldn't. You should, however, be able to replicate a users actions to make the element visible and then click it
find('#button_div').hover
find('#icon').click
if that doesn't raise an error but also doesn't appear to click the button try putting a short sleep between the two actions since you may have an animated appearance which can cause clicks to miss items
Try using .execute_script() as below :-
button_div_element = find('#button_div').native
button_element = find('#button', visible: false).native
page.driver.browser.action.move_to(button_div_element).perform
page.driver.browser.execute_script("arguments[0].click()", button_element)
Hope it will work...:)
After some painstaking trial and error, I managed to find a solution that worked
button_div = find("#button_div_id").native
icon = find("#icon_id").native
page.driver.browser.action.move_to(button_div, :right_by => -50).click.perform
icon.click
Not sure why I had to manually tell Capybara to go left by 50px, but that seems to have done the trick.
Also, I added the following line to my setup code:
page.driver.browser.manage.window.maximize
This makes sure the window is maximized before running the test. I'm not 100% sure, but this might have also had something to do with the fix.

Need help on clicking an element (Element is not clickable at point (62, 459)) - Capybara Ruby Selenium Automation

I am having below error message in my console while trying to click on a button element:
unknown error: Element is not clickable at point (62, 459).
Other element would receive the click: <i class="foo foo-chase-lemon font-size-13"></i>
Here's my code below:
#object = Page.new
#object.wait_until_btn_element_visible
#object.btn_element.click
I have tried with retry 5 times to click on it using rescue but didn't help.
Below code also didn't work where i tried to move to that element before click.
Capybara.page.driver.move_to.(#object.btn_element).perform
Any solution will be greatly appreciated.
I tried increasing the resolution/ scrolling the window. None of them worked on this specific scenario. These solution might work for others.
However, I resolved the issue by clicking the button using javascript "execute_script" method in my automation script.

Wicket replacing panel with ajax fails with MarkupNotFoundException

the page markup has
<div wicket:id="stepPanel" />
tag in it and when the page is first loaded it works great that is
add(new MyFirstPanel("stepPanel"));
works fine. But then when I trigger an Ajax event and request redrawing
addOrReplace(new MySecondPanel("stepPanel"));
target.add(MyPage.this);
i get the following error
Last cause: Failed to find markup file associated. MyFirstPanel: [MyFirstPanel [Component id = stepPanel]]
please note that it tries to find the wrong markup (should look for markup for MySecondPanel) and it fails regardless it succedded to do so before!
I instantiate panels using reflection, but could it be a problem here? No exceptions thrown.
Anwser:
Actually it was something else - I have noticed that one of my AjaxSubmitLinks had reference to a form that was no longer placed in a markup... so whatever you do just remember not to leave that reference.
You are adding MyPage after replacing the Panel causing MyPage to re-render.
There is a good example on how to replace panels here.
Yes you can call panels via reflection. I don't clearly know what you are trying to do with event here but if you want you can attach your panel with AjaxSelfUpdatingTimerBehavior and define the duration which will update this component in the given time period.
Hope its useful.

jQuery error - Uncaught Error: can't load XRegExp twice in the same frame

I have a button, onclick of which I'm doing an AJAX call to one of my pages (which contains jqplot elements).
Now, the AJAX req/res works fine for the first click of the button.
When I click my button for the second time, I get an exception saying,
Uncaught Error: can't load XRegExp twice in the same frame
And it points to the jQuery-min file. Any idea on how I can solve this issue?
I have tried this solution and it does not work.
I think the handler is getting "attached" before the DOM element in question actually exists.
Try using jquery.on().

Customizing jQuery validate to pop-up error message over an icon

This might be a fundamental jQuery misunderstanding but I've got to ask...
I'm trying to get the jQuery.validate to display its error messages on qTip, a jQuery plugin for customizing tooltips. Specifically I want to get the tooltip to pop-up on mouseover of a little red "X" icon.
I can get the tooltip to popup over the form field using the following code:
$().ready(function() {
// validate signup form on keyup and submit
$("#signup").validate({
errorPlacement: function(error, element) {
element.parent().parent().append('<div class="rederrorx"></div>');
element.qtip(
{
//qTip formatting and content code
});
},
But to get the tooltip to pop up over a red x, I change element.qTip( to $(".rederrorx").qTip( and it doesn't work (no message/qTip initialized).
Has the concept of selectors just gone way over my head? Prob so. Or is the jQuery class selector not selecting anything because the append has yet to take place? Or...
Thanks!
Emile
I replaced element.parent() with element.parents('.classname') in order to pinpoint the exact parent element I wanted. I'm assuming a plugin added nested divs without telling me. No other answers....
lo siento for the stupid question

Resources