Chrome extension: enter value in text field via UI instead of javascript? - google-chrome-extension

The input field I am trying to utilize does not respond to changes to only it's value so I'm wondering if there's some API similar to selenium that will allow me to perform UI testing-like actions so I can enter in the value via clicking, entering keys rather than via javascript? Basically, is it possible to input a value into a search box WITHOUT javascript within a chrome extension?

Related

Chrome Extension API: capturing specific tab

Right now I developing a product based on Chromium extension which monitors user actions by taking screenshots on several DOM events, such as mouse "click". I using chrome.tabs.captureVisibleTab API for doing that.
The problem: if user makes a click on tab "A" content and then very fast choosing another tab "B" - captureVisibleTab takes screenshot of currently visible tab "B" (instead of tab "A", where action happened).
This is because it take some time while "click" message passing from content script to background (asynchronously) and screenshot taken (also asynchronously) and during that time another tab already activated.
One possible solution I had been thinking is instead of using "captureVisibleTab" - use some another capture API which takes tab id as an argument - but I cannot find such API.
Any ideas?

Search Salesforce with selenium

I am trying to use selinum for chrome with Salesforce to search the salesforce for case number.
I am able to login and write the case number in the salesforce search box, but I am not able to retrieve the output.
My code:
# create a new Chrome session
driver = webdriver.Chrome(chrome_driver_path)
driver.implicitly_wait(300)
driver.maximize_window()
# Navigate to the application home page
driver.get("https://salesforce.com/xxx")
driver.implicitly_wait(100)
search_field = driver.find_element_by_xpath("//input[#title='Search Salesforce']")
search_field.click();
search_field.clear();
search_field.send_keys("case number").wait();
driver.find_element_by_xpath("//span[#title='case number']");
search_field.click();
driver.implicitly_wait(10)
search_field.submit();
search_field.sendKeys(Keys.RETURN);
Since I am not able to make comments due to lack of reputation points, this is what I wanted to add to #RockinWatson's response above:
There is a chance that the 'value' attribute does not get updated after you enter value in search field. In that case, either
click somewhere outside of the box
or hit tab using search_field.sendKeys(Keys.TAB);
or hit enter using search_field.sendKeys(Keys.RETURN); as long as it doesn't take you away from the page.
You will have to get the value Attribute from the element after entering the text.
input_text = search_field.get_attribute("value")

Is there a way to get the ID of the textbox created by ZeppelinContext's z.input

I have a spark based note in Zeppelin, where by using Javascript I want to modify the text in a text box created through Zeppelin's z.input. Is this even possible? I mean, can I get the ID of such a texbox so that I can modify its value through Javascript's HTML DOM functions.

Is it possible for a chrome extension to detect if it is in the dropdown?

I'd like to use the same HTML file for multiple purposes - a login panel in an iframe in the browser, as well as a login panel in the dropdown.
Is there a programmatic way to know if I am in the dropdown versus anywhere else?
I've looked through the window object and I can't find anything unique that indicates that I am in the dropdown.
I would prefer not to use a custom URL for the dropdown (query parameters or somethinig like that).
If you mean a popup from a Page Action or a Browser Action then you can get the chrome.windows object and read the type property.
chrome.windows.getCurrent(function(window){
//window.type is an enumerated string ["normal", "popup", "panel", "app"]
});

Key binding on a flash page

I would like to know if the following is possible - I'm having trouble finding information regarding my question on the web. I was looking into creating a Google Chrome extension to work with a webpage, until I realized that the page was in fact built with flash. Originally I wanted to bind an onClick event for an input on the webpage to display a form (which would be through the extension I'm building).
However, because the page is build in flash I no longer believe that this will be a possibility. So, my next idea was to bind the form's loading to a certain combination of keys (ctrl + d) for example, that the user would click.
For example:
The user is using the flash form with my extension running in the background. The user focuses on an input (text box let's say) and proceeds to click the keys (Ctrl + D). Upon clicking these keys, my extension pops open a web-form. The user types in what he wants in the form and then clicks "Save" - A submit button on my web-form. When the user clicks 'save', the data from the web-form is stored in the clipboard and the form closes. Finally, the focused input is filled in with the data from the clipboard.
Two questions:
Do Google Chrome extensions support key binding like this?
Will I be able to copy input from my generated form (through the extension) and paste it back into the input field on the flash page?
1. Do Google Chrome extensions support key binding like this?
Yes, you can specify custom key board shortcuts catered to platform using chrome.commands API.
You can directly trigger browser action\page action popup page or do any customized functionality by defining a key.
Sample Code of manifest
{
"sample": {
"suggested_key": {
"default": "Ctrl+Shift+S",
"windows": "Ctrl+Shift+P"
},
"description": "Thisismycustomkeyforchromeextension"
},
"_execute_browser_action": {
"suggested_key": {
"windows": "Ctrl+Shift+Y",
"mac": "Command+Shift+Y",
"chromeos": "Ctrl+Shift+U",
"linux": "Ctrl+Shift+J"
}
}
}
However, maximum of 4 keys are supported so far! For further information refer this answer
2. Will I be able to copy input from my generated form (through the extension) and paste it back into the input field on the flash page?
Yes, with combination of content scripts and message passing it is possible.
References
Content Scripts
Background Pages
Message Passing
Commands API

Resources