I'm writing a chrome extension that needs to do some work when the user submits a form. I've got a content script running in the background that runs the following code:
$(document.body).on('submit', 'form', function () {
doWork();
});
That works perfectly on most sites, but breaks on the login form of twitter. Oddly, though, it doesn't break entirely. If I click the 'Sign In' button on twitter, the doWork() function will run. However, if I press enter to submit the form, doWork() never runs.
In my efforts to debug, I then copy and pasted my code into dev tools to rebind the function, and see if it worked. It did - even when using enter, the new binding worked.
My next thought was that maybe jQuery.on wasn't working on elements created via javascript (assuming the button submitted a hidden dynamically-created form via javascript, rather than the visible form, for some reason). So, I rebound the event like above, but added in a line that would alert me with the class name of the submitted form - all of the forms have unique class names on the twitter login page.
As you may have unfortunately guessed, clicking 'Sign In' vs. pressing enter alerted with the same class name - so, no matter which way I look at it, I have an event bound to that form submit, but for some crazy reason it is not getting called when I press enter.
Related
I have a website (private, sorry) that I'm trying to log into automatically but the login page has no source code available so am unable to assign/find specific elements.
The cursor is blinking on the Username input field, so trying somehow to start typing then tab to password field and then enter.
I've tried the following three different methods, neither fills in any text.
ActionChains:
actions = ActionChains(driver)
actions.send_keys("*username*")
actions.perform()
Passing info to the url itself:
driver.get("https://username:password#my_website.com")
By active element:
active_ele = driver.switch_to.active_element
active_ele.send_keys("test")
I'm guessing your target page is protected by Basic Authentication, and what you're calling the "login page" is not an actual "page", but rather the browser's Basic Authentication dialog box. This "pop-up box" is not an actual page element, so you can't manipulate it with Selenium's page-element API.
In my own Selenium code, with current Chrome (version 90), the "https://username:password#my_website.com" URL does actually work to open the target page. However, it doesn't "fill in any text" like you said; it just directly opens the protected page. Also, a "https://username:password#my_website.com" URL doesn't work in the browser address bar itself; it only works in the Selenium API. Also, my tests are in C#; FAIK the "https://username:password#my_website.com" technique might not work in Python.
Note, Chrome removed the "https://username:password#my_website.com" feature for years, but then they brought it back, sometime before November 2019, when I discovered it; but they only brought it back for the Selenium API, not for the browser address bar.
For example, on page I have a button, which causes to fire XYZ function (which is already loaded inside namespace in external JS).
However, I wanted there to change only one function in that script only (not page), and reload that script again, so, that the BUTTON will fire the modified function..
How to do that?
Shouldn't be a problem.
You can use the console to redefine the function.
Just click F12, go to Console,
then type in your edited function and click enter.
Then click the button and the modified function will be executed.
Note When editing the function from the console, make sure that you are in the right context:
If you type the function name and get a function this means you can edit it. If you get undefined, this means you are not in the right context and should change the scope in which the function is defined in.
You can change scope in Chrome's console if needed by using this dropdown (for example when the code is run from an iframe):
I'm using Notes/Domino 8.5.3. I've added a button control to an xpage. The button uses a Confirm Action to display a client-side prompt to the user before continuing with the next action defined for the button. When I use static text for the Confirmation Text for the Confirm Action, the confirmation prompt is displayed. However, when I change the Confirmation Text to be computed, and retrieve the text from a profile document, the confirmation prompt it not displayed at all in XPiNC. The confirmation prompt with the computed confirmation text is displayed just fine in a browser. Is there a work-around for this issue with XPiNC?
Following is the code I'm using in the Confirm Action to get the text for the prompt:
var server = database.getServer();
var dbProfile:NotesDocument = database.getProfileDocument("DBProfile", "");
var msg = dbProfile.getItemValueString("ContactsInitUpdatePrompt");
return msg;
To further my comments, this is a work around I use the below code for an app that uses the bootstrap extension library on the web but uses basic functionality with xpinc.
If the values for xPinc are different you could make the confirm action different in the browser and in the client.
if (#ClientType()== "Notes")
{
<action>;
}
else{
<action>;
}
I think that profile documents are a bad idea in xPages though. Having to restart HTTP to get a new value ruins the point I think. Almost better to hard code values at that point. I think you can set application scope to handle the work of profile documents. But then application scope in xpinc is just on the current machine as the server is the client.
In our JSF web application, we have an input field where the user can enter a numeric ID, which is then looked up by the app. To help the user, the lookup is bound to "onchange", thus it will be triggered as soon as the user tabs out of the field or clicks elsewhere.
So, user enters "123", presses tab (or clicks), lookup runs. This works fine; however, for usability reasons, we also want to provide a button that users can click on, for users who will otherwise wonder "where should I click to trigger a lookup?". To do this, we'd like to provide something that looks and feels like a HTML / JSF button, but does nothing (as the click will trigger the "onchange" event anyway).
Is there a way to make a JSF button that does nothing? I tried using h:commandButton without the "action" attribute, but it still fires a request.
p:commandButton type="button" will just provide a push button.
Since you tagged this question also as a usability issue, I would advise against a button in the first place if the onchange already triggers the lookup.
From a user's perspective it is confusing whether or not clicking the button is mandatory. After they have entered the field and skipped to the next, they see the lookup occur without clicking the button. If there is a button they will assume it's there for a reason.
The option that I favour in these cases is a onkeypress handler with a timeout of half a second, after which the value is looked up.
I've set (and confirmed in the database) nodes under the content type miniapps to have the alias content/miniapps/9999/test (where 9999 is a node's actual id, and test is the node's title. Everything works fine when a new node is added - i.e. I get redirected to the proper page. However, when I edit that page and press Submit, I get the "page not found" error. If I manually enter the above path in the browser I go to the proper page. This happens even though every conceivable permission has been set, and in fact happens on my (the super admin) content. Any guidance or suggestions on why the wrong redirect appears to be assigned by the form submit button handler. Thank you very much.