Set focus() back to contenteditable - contenteditable

I'm building a mini WYSIWYG editor with a modal window (Twitter Bootstrap) for entering image paths. The workflow is like this:
User is editing something in the contenteditable div and wants to insert an image
User clicks the image button, the modal window opens
User enters some URL into the input field and hit the enter key
Now I'm trying to focus() back to the contenteditable div. Unfortunately it seems not to be focussed, because things like document.execCommand() don't work.
In other words:
How can I bring back the focus() to the contenteditable div after being in an input field?
I have seen a couple of solutions for that, some with big scripts doing some Range/Selection-stuff, but I'm sure there is a much simpler solution for this...
Anyone?

Related

robotframework- unable to click a button on a modal dialogue box

when I open a particular webpage it has a EULA form that appears on top of the home page in the form of a modal in HTML/CSS. I have tried the XPath of the accept button but it says element not found also tried using handle alert.
is there a unique way to handle a dialogue box in robotframework?
image of HTML in inspect view
SeleniumLibrary.Set Focus To Element ${button_on_popup_page}
SeleniumLibrary.Click Element ${button_on_popup_page}
I figured it out, shown in the above code. I first set focus to the button and then used the click element. This seemed to work.

How to unfocus from all inputs/elements in Selenium without tabbing out

I have a form where I fill in textboxes through selenium (java). Some of the textboxes dynamically generate extra content when you click on them and remove the content when you focus on something else. This is a problem when I automate because if I am focused on a text box and try to click on something else, when the page removes the content it doesn't register my click and I need to click again. This leads to flakey behaviour since I need to now consider whether I need to click or double click a button depending on what element I was focused on before.
I can't send a tab key to the text box because sometimes it will tab into another textbox that has the same dynamic generation behaviour, leading to the same scenario as before.
I tried clicking the page element but it also doesn't seem to work. I also tried clicking the root div. It just doesn't seem to register my click (I also tried jsclicks)
What I would like to do is have a general way to unfocus a text box after I fill it.
Thanks!

Using puppeteer to automate button clicks for every button at every URL in a web app

I am currently trying to use JS and puppeteer to take a screenshot of every url in my web app, as well as take a screenshot of every button that can be clicked. Is there a way to click each button without specifying the id? Not all of my buttons have an id and even if they did, I wouldn't want to have x number of page.click(id, options) for each button I have (which is quite a lot).
Thanks
I have tried going based off each className (this app is built using react) but this does not work. It will take a screenshot of the same buttons over and over. I believe because if page.click has multiple of the same options, it only chooses the first one and many buttons have the same styling classNames.
You could get an array of each element on a page, go through the elements with a for loop determine if it is a button, then click it. Then for each page you'd have to input each url in an array and then use a for loop to go through it.

Give focus to text-entry field in prompt in node-webkit

In most browsers, a javascript prompt() gives focus to the text entry field so the user can begin typing immediately.
In node-webkit, a javascript prompt() gives focus to the prompt window, but not the text entry field. The user has to click inside the field before typing.
How can I set the focus to inside the text entry field when using a prompt in node-webkit?
An extensible way is to create your own prompts with a javascript modal window. Many of the common JS frameworks have easy ways of creating a modal window which will give you complete control over the text and inputs being displayed.

How can I give focus to WinJS.UI.settingsFlyout after animation?

I'm invoking a WinJS.UI.settingsFlyout element via Javascript using WinJS. Inside the HTML element of the settingsFlyout, I have a text input field that I would like to receive focus after the animation of the flyout occurs. I've tried to use jQuery's .focus() method, but it does not work because I do not think the flyout is focused after it completes its animation. I have to click twice on the input field to begin typing. I click once to get the flyout in focus, and then click another time to get the field in focus. Quite annoying. Is there a way to implement auto focusing of input fields within a WinJS.UI.settingsFlyout?
Have you tried?
settingsFlyout.addEventListener("aftershow", function(){
$('#inputId').focus();
});