Is there a way in Sublime Text to detect before window is closing to add a custom command?
I run a custom command with this shortcuts:
[
{ "keys": ["ctrl+shift+w"], "command": "custom_command"},
{ "keys": ["alt+f4"], "command": "custom_command"}
]
But there are other ways to close Sublime Text and makes sense that a before closing window event should cover all.
There is an event handler function that gets called before a view is closed. I think the name of the function you need is
on_pre_close(view)
All event handler functions are listed within the Sublime Text 3 API. I didn't find one for when the window is closed but I think when the window is going to close, it should close each view first, so using the above function should solve your problem. Here is the link to the Event Listeners section of the API. It should help you.
https://www.sublimetext.com/docs/3/api_reference.html#sublime_plugin.EventListener
Incase you are new to building plugins,
Note that to use Event Listener functions you will need to have a plugin in which you have a class like this
class your_class_name(sublime_plugin.EventListener):
def on_pre_close(self,view):
#Your code here
Maybe python's atexit https://docs.python.org/3/library/atexit.html would work.
(I have not tried it - it is possible that python plugin API will not be fully working at the time atexit functions are called)
Related
I have written codes to click on hyperlink then check the new window URL.
cy.get('a[href*="newlink"]').eq(0).click()
cy.url().should('equal', 'https://www.google.com')
how do i close this window / or not close AND back to the original main test window?
here's a solution i use for swapping between popup windows: https://github.com/jakedowns/CypressHelpers
it would need some tweaking to work directly with .click
but it does enable cy.openWindow and a new cy.switchWindow / cy.closeWindow
under the hood it uses an undocumented
cy.state('document') and cy.state('window') method for context-switching
cy.go(direction, options)
See the documentation for examples
This works for the history in the same tab. Cypress does not support multiple tabs.
you can use cy.go('back')
see here
Packages and methods in Visual Studio Code all auto complete after hitting tab (Golang), which is great, but I want it to complete the method and then put the cursor inside the ( ). I had it working like this on another machine but I can't seem to find setting/extension that does this.
Example:
// before hitting tab
fmt.Pri
// after hitting tab
fmt.Println
// would like this after hitting tab (with cursor inside parenthesis)
fmt.Println()
Any help is appreciated.
I finally found it. Inside your settings.json you need the following line.
{
"go.useCodeSnippetsOnFunctionSuggest": true,
}
I have the Go ms-vscode.go extension enabled, not sure if this is relevant but just in case.
There's a few issues about this on Github. Seems they don't want to implement it as standard because it would interfere when you want to type a function reference instead of a function call.
VSCode extensions can provide "snippets", which insert code based on a prefix and include the concept of tab stops. This is not really what you're looking for but I'll draw your attention to it anyway.
You can implement more advanced functionality with a language server that listens for events in the document. If you wanted to write it yourself, I think you would need to create a language server extension.
I just noticed this in the trunk/dev channel:
type ( enumerated string ["normal", "popup", "panel", "app", "shell"] )
The type of browser window this is.
I tried it with with Canary: no window is shown, but we have console output, so something has been created. The thing is I just don't get it. How is this different from a background page?
I was hoping to toggle windows completely out of the user's view, without having to reload the window's content when toggling up. Anyway, I'm not hoping much as you can't update a window type with chrome.windows.update. But the question still remains: what is this "shell" type?
"shell" moved to the new chrome.app.window API in r140947. Then it appears to have disappeared from there in the dev documentation.
"shell" currently does nothing for extensions and should not be used.
I've followed the Google app script tutorial here which is a very simple script with two functions. showDialog (which presents a dialog box with a text field and submit button ) and respondToSubmit(e) which handles the submit button and adds the entered data to the spreadsheet.
It works fine.
What doesn't seem to work is the debugger on the callback. So I place a breakpoint in both functons and start the showDialog function. The debugger kicks in and stops execution at the breakpoint. I click continue so I can interact with the newly opened dialog box. However when I click the submit button the debugger does not start again. The respondtoSubmit(e) function is executed. The debugger just does not stop on the breakpoint(s).
Is there a problem with debugging callbacks like this or can you only debug one function at a time?
For reference Utilities.jsonStringify(e) is depricated, use JSON.stringify() and JSON.parse() instead.
As of right now, the debugger has some unexpected behaviours. Mostly, it seems to only respect breakpoints during calls from the script editor, so to debug your event handler you must call it from the debugger, not the UI. If you need to peek into variables such as the event object passed to the function, for example, try adding this line to your handler where you'd normally put a breakpoint:
Logger.log(Utilities.jsonStringify(e));
Then view the log from the script editor after execution.
It seems to me that the Logger does not work either, unless run from the script editor. I did manage Browser.msgbox(Utilities.jsonStringify(e)) which had brought the (expected) result:
{"parameter":{"clientY":"45","clientX":"37","eventType":"click","ctrl":"false","meta":"false","source":"u12053277590","button":"1","alt":"false","myTextBox":"babi","screenY":"381","screenX":"598","shift":"false","y":"13","x":"33"}}
I'm new to the testing world, so my question might seem a lil' bit too naive and stupid. At risk of looking/sounding stupid, my question is this:
I've been trying to test the contents in a pop-up window on my company's web app. I've figured out how to detect the pop-up window for now, but i can't get selenium to 'click' on the link inside of that pop-up window. there are multiple pop-ups in this web app so it's really difficult for a newbie like to create a test case.
I tried the click, clickAndWait, mouseDown and mouseKey as an option but it is still not working. can somebody guide me through this?
TIA,
Angela
When the popup appears you will need to move the context of the script over to the window.
You can do this by using the selectWindow | window_ID_from_the_link and then do the clicking.
If that doesn't work you may need to use the openWindow command to create the popup and then start testing against that.
Use getConfirmation/getassert/getprompt according to the type of the pop up you use .....By default they will be clicked with ok option by the server and you have to consume the message from the pop up for the other selenium commands to work correctly.............
The above suggestion is given from my experience in working with selenium RC used with perl..........
Perhaps you can try the FireFox Plugin. You can click through your application and record your steps. After recording the steps you can easily save it as some sort of file or unittest.
I'm not sure about the command you should use for the popups, maybe the firefox plugin will help in this manner (it will create your commands).
If you created the popup with a div tag, U can use following code to stop the selenium server until the popup opens.
int second = 0;
while(!selenium.IsElementPresent(mylink))
{
if(second >= 5)
break;
Thread.Sleep(1000);
second++;
}
After a popup opens, Now you can click on any link inside the popup.You have to use the below code.
selenium.click("id=popup_link"); (popup_link is the id of the link present on the popup)
Good Luck.
Not sure if this is what you are looking for, but if you want to click on something specific that Selenium is not able to handle - like browser pop-ups or other pop-ups, you can use Sikuli Script. Sikuli does an image comparison and clicks on the same - this is very powerful.
Here is the link: http://www.sikuli.org/