I'm writing automated test using Selenium WebDriver and ruby. I faced with such problem:
I need to close popup, but close-button for popup is outside DOM. In DOM I have div element with class 'promotional-wrapper' and this element have attribute data-mage-init='{"promoPopUp": {"url": {"getDataUrl": url from where DOM is updated with new nodes}}}' This div is responsible for getting popup into the page.
How to access element not directly attached to DOM?
Classic methods to get element by xpath fail, I get 'Stale Element Reference Exception'.
But interesting that when I accidentally ignored popup and wanted to click somewhere else click was intercepted by popup.
I think the pop up is being added to the DOM after you click.
so you should:
click the //div[#class='promotional-wrapper'] element
Wait for popup [exact locator TBD]
then search for element you want to interact with
The popup WILL be in the DOM after you launch it. Unless the popup is another window, in which case you will need to learn to deal with switching to windows: https://stackoverflow.com/a/36429462/1387701
Related
I have a situation where a toolbar item in CKEditor5 opens a ContextualBalloon which contains an iframe.
In my current understanding, the only way to hide the balloon is to remove the iframe view i.e.
this.balloon.remove(this.colorPickerIframeView)
However this removes the iframe view from the DOM, meaning that the next time I open the balloon view the iframe is reloaded.
I'd rather not have to reload the iframe every time, is there any way around that?
If you want to only hide the ContextualBalloon's view you can try to use this.balloon.view.hide()
I'm using a RadComboBox in the load on demand (lazy) mode with a web service.
I'm using a client side item template of this form: <input type='checkbox' id='cb_#= Value #'/><span>#= Text #</span> (adding a checkbox before each item's text)
In the itemDataBound client side handler for this RadComboBox I'm retrieving the particular item's DOM element and the nested checkbox'es DOM element and adding a click handler function for each of them (using jquery's $(element).click(function() {})).
The click handler functions work fine until I scroll the items out of view and then scroll back, after that the click handlers are not called anymore (the checkbox selection is also lost).
I suppose this is because the DOM elements representing the items get re-created as they are scrolled in and out of view. But the itemDataBound event is raised only once and is not raised again when an item is scrolled back in view.
The only workaround I can think of is to use the onclick attribute in the HTML and reference a global function from there, but this is ugly.
Is there a nicer solution for this then using the onclick attribute?
What it does actually it appends to innerHtml of the list element, but this is effectively re-moving and re-adding every node under the list element.
I worked around this by assigning my click hander and doing the databiding in the itemsRequested client side handler, iterating over the entire list of items obtained with the get_items() method of the RadCombobBox client side object.
itemsRequested is called every time after new items are added to the list and therefore every time after the DOM is re-created.
I would like to create a usual dialog window:
The user clicks a link or button
The screen becomes blackish, a new window appears (a DIV is created)
By using Ajax, the DIV is populated with a form.xhtml
By clicking on a cross in the DIV, the DIV is removed and the blackish screen too.
I know how to do some of this stuff with usual CSS/Jquery. However, I am lost on how the JSF link/button should call the Jquery code to create the dialog (because I am supposing that JSF cannot do it alone) and make the Ajax call to get the form.
I am not using auxiliary libraries.
I deal with a question.
I want to load some content via ajax when user click on a text.
Does it matter to use <a> element or <span> element for this text while we can call click() for both of them?
Does it matter for search engines crawlers as I know from before they don't run js codes?
how i can get (if)any text is selected in textbox and i want to get it in any variable of javascript.... specifically for Mozilla firefox...?
the above description is not enough so let me give completely the definition.. My Extension of firefox is an Extension that double clicks any word from the webpage and finds its possible meaning from database... so user can even write anything in Textbox and double click the same for finding its meaning.. so please do suggest any way to complete selection from textbox's selected text....? in addition i am already using dblclick event handler so dont suggest that solution.... Also the problem is that the web page can be any site's webpage so even the textarea or any control is specific tho that page how could i slice the text from it than ...Thanxx in advance....
You can use document.getSelection() which returns a selection object containing the currently highlighted text in the document. However, calling it at the right time can be tricky. You can't do it from an onclick handler on a button, for instance, because by the time the onclick handler fires, the selection's focus has been removed from the text and moved to the button.
Use the selectionStart and selectionEnd properties e.g.
var selectedText = textbox.value.slice(textbox.selectionStart, textbox.selectionEnd);