Chrome Extension - Devtools - invoke element selector programatically - google-chrome-devtools

I want to invoke the "Element selector" to be invoked from dev-tools js or background js. I checked the chrome api documentation and could not find a direct .
I referred to this solution. It is launching an inspect session with the supplied argument ex.
inspect(document.body)
I want to allow user select the element. I want to reuse the element selection facility given by devtools inspect element
Could you please point me to an api or any set of statements by which I can achieve the same?

Related

Is there a way to retrieve information from a ui element that has the property IsControlElement = False? (Python + Appium + WinAppDriver)

Greetings and salutations!
I'm working on a UI automation project for a windows desktop app (FrameworkId: Win32)
Stack: Python (3.7) + Appium (1.15.1) + WinAppDriver (v1.1).
I have identified an element using Inspect.exe, but when I try to code, whatever I do I receive this error:
selenium.common.exceptions.NoSuchElementException: Message: An element could not be located on the page using the given search parameters.
The locator strategy I'm using is xpath:
self.driver.find_element_by_xpath("//*[#LocalizedControlType='text' and #IsControlElement='false']")
As you can see, Inspect.exe has shown that it has the property "IsControlElement='false'", but I cannot for the life of me "access" it via code.
I would also like to point out that any elements that had the IsControlElement='true' are properly found and I can "interact" with them.
Thank you very much for your help!
Source of issue
This is probably an issue within Microsoft's UI Automation implementation in .NET.
The property IsControlElement should have returned true while it didn't.
From my tests, it seems to be an issue somewhere within UIAutomationCore.dll.
I speculate that the root cause is that the automation implementation was targeted for accessibility in mind, and they have mistakenly ignored some controls which are NOT readable (Image, Geometry, etc.).
Workaround for some cases
Try to use UI control from a type that has a text.
if it's already a textual control, try to use a different textual control type. for example - in WPF project - use Label instead of TextBlock
if it's NOT a textual element, if possible, wrap the control in a textual element. in WPF projects you can use a <Label Padding="0"> as a wrapper.
Other things to consider
Try to use UIAComWrapper
Related issues
https://stackoverflow.com/a/46452431/426315
UIAutomation won't retrieve children of an element
UI Automation - #32770 (Dialog) shows in Insepct.exe but not in VisualUIAVerifyNative.exe
Side Note
Since you haven't specified which Python GUI library are you using, I was not able to provide examples for your library. Sorry.

Emulate click in Google Console for Chrome settings page

Google chrome settings page prevents me to delete a default search engine (drop down menu allowing to do so does not show up on click in browser). Yet the path to the hidden #delete button is easy to find in the inspector. My problem is to emulate a click in the console.
I've tried many combinations along the lines of:
document.querySelector(path).click();
Here's an example with the full JSpath
document.querySelector("body > settings-ui").shadowRoot.querySelector("#main").shadowRoot.querySelector("settings-basic-page").shadowRoot.querySelector("#basicPage > settings-section.expanded > settings-search-page").shadowRoot.querySelector("#pages > settings-subpage > settings-search-engines-page").shadowRoot.querySelector("settings-search-engines-list:nth-child(11)").shadowRoot.querySelector("#container > iron-list > settings-search-engine-entry:nth-child(3)").shadowRoot.querySelector("#delete").click();
I simply get "undefined" as an error message.
https://i.stack.imgur.com/O3h8f.png
image description: Here's the front end issue I run into when I try to delete the default browser.
Chrome doesn't allow to remove the default engine: it performs the check explicitly in its internal C++ code so you'll have to make another engine a default one beforehand.
And here's a simpler command to delete the engine at index 1, that is the second engine in the list:
chrome.send("removeSearchEngine", [1])

How to get $ to select css in google chrome

I'm on version 58 of Google Chrome on MacOS. When I try to do a $('#userName') type selector, I get the following:
$('#userName')
VM193870:1 Uncaught TypeError: $ is not a function
at <anonymous>:1:1
(anonymous) # VM193870:1
However, according to this page, https://developers.google.com/web/tools/chrome-devtools/console/expressions#select_elements, I should be able to do that without any problems.
$$('#userName') does work and returns the list of a single element.
$$('#userName')
[input#userName.ng-untouched.ng-pristine.ng-invalid.mat-input-element]
Is there something I need to enable?
Further investigation revealed that the angular 2 app I'm working on somehow clobbers the $ operator. If you are experiencing this issue, first check to see if it will work on another website (use a different tab). It may also be an extension that clobbers it.

How do NPAPI Plug-in accept command+o event?

I got into a trouble, because my plug-in want to open file dialog when using command+o,but the safari holded on this event.Anyone has a solution?
I strongly suspect there is nothing you can do about this; as a plugin you are a second class citizen, a guest in the process.
You can accept the command event, you have to listen to set a callback for the event member of NPPluginFuncs struct in NP_GetEntryPoints method.
In that method you'll receive all mouse and keyboard events, as well as window focus events. You can cast the second argument from void* to NPCocoaEvent where you will find all necessary parameters suchs as event type, mouse state, keys and focus data.
Please check which event type you're handling before digging into the 'data' union of NPCocoaEvent, otherwise you can get an EXC_BAD_ACCESS.
I'm having trouble with sharing commands with the browser, in my case Command+O should fire the plugin's file open dialog only, but it's also firing the browser open file dialog. Supposedly, returning TRUE for event handling method should report the browser that the plugin handled the event, but I'm having no luck yet.

JStreeGrid Microsoft JScript runtime error: Object doesn't support this property or method

I'm using the JSTreeGrid in an ASP.NET application. The implementation of the JSTreeGrid works fine in the application in which it was designed in tested. However when I moved it over to another application I recieved the following error message below:
Microsoft JScript runtime error: Object doesn't support this property or method
When I initially moved the implementation over I discovered and corrected issues related to the new application forms utilizing Masterpages. The container names were concatenated to the div tags and the scripts were not finding the declared div tag IDs specified in the script. The application that I moved it from did not use Masterpages. I feel resonably certain that the error is related.
The error occurs in the _prepare_grid: function in the jstreegrid script when obj.each(function () section of script is run.
Any insight would be appreciated. Thanks
When you use master pages the Client ID of your DOM elements ia manupulated by the server.
This is due to the chace that you will use the same id both in the master page and in your derived page... when calling Jquery function i would guess that you use id selector i.e. $('#someID').doSomething() ...
When using master one of the solutions is to use the following selector as an exmaple:
$('[id$=myButton]').click(function(){ alert('button clicked'); });
This means that Jquery will select the element with an ID attribute that end with 'myButton'.
for more information follow this post.
How to use JQuery with Master Pages?