I am facing a problem, can anyone help me to sort this out:
Background: I have to create a backup of the code exist in the editor(Code mirror), so the use case is I have to copy the code from the editor and save it as .html file.
While using the element.getText() and writing to a file works fine but the issue is the getText()only get the code visible on the screen. Since the code lines vary so if I use javascript scrolls then it didn't work as some page on the editor (code mirror) would have 100 lines of code or some may have 2000.
Another solution I tried is to use Action class i.e mouse actions means Select all and copy i.e Keys.COMMAND, "c")).perform();
The Problem is here how can I copy the selected text to the clipboard or save the copied text to the string so that I can execute BufferedWriter class.
Would appreciate if anyone can help.
Sorry I misunderstood your question.
For the link https://codemirror.net/demo/theme.html, to get the code, I think you should first scroll to the bottom of the editor using executeScript(Scroll to bottom of div?). After that, element.getText() should give you full code.
Update: You can also select the text by clicking on the editor and then pressing Ctrl + A, after that get selected text by executing javascript on the browser (Get the Highlighted/Selected text). You can then handle the text within your test script.
Related
I would like to remember my team the ports used for debugging, for several projects.
A Ctrl-F in a directory, and I have my results under IntelliJ_2021.1.3 Ultimate I'm using,
but I have no way to paste them, like they are on this window, either with Ctrl-C or Ctrl-Ins , on another location in order to send a mail to my teammates.
Does a workaround exist, or has this feature been implemented in a later version I should try to upgrade to?
I don't think there is a simple and direct way to do what you want. However, there is a workaround:
Run your search, and then from the Find in Files window click the Open in Find Window button:
Right-click anywhere within that Find window listing the occurrences, then select Export to Text File from the context menu:
An Export Preview window will open, showing the search results in expanded hierarchical form, reflecting the structure under the directory you searched. Within that window you can select any contiguous portion of text, then right click and select Copy from the context menu:
You can then paste the selected text into any other window, and massage the results as necessary:
Notes:
This is only a workaround because unfortunately I don't see a way to directly copy the results in your screen shot, in which each line shows a both a search occurrence and its file location. That information is still in the copied text, but it may take a bit of effort to get it in the form you want.
The Copy button in the Export Preview window ignores any text selection and blindly copies everything, so use Copy from the context menu instead if selecting a subset of the text.
I used IntelliJ IDEA 2023.1 EAP (Ultimate Edition). I don't know whether this functionality exists in your version.
I'm using IntelliJ and VSCode and i'm wondering if there is a way to mark a part of the code and the tool will only display and focus on that code and will make the rest disappear. This will help to get rid of clutter code that i'm not interested in.
You can point the cursor over the code block you want to focus on, press Ctrl+Shift+NumPad - to collapse all code blocks and press Ctrl+NumPad - to expand the selected one. See Write and edit source code | Code Folding for more information.
In addition you can consider using Distraction Free Mode.
I'm trying to download a CSV file by clicking on a link that's located on a hidden table, but I can't make it click on it. The href will change, so I can't use it. I tried to locate it by xPath, partial link text, link text, class name... I also tried to first access the "table" where the button is and then click on the link, but it didn't work as well. Oh, I tried to execute the script too
The table is hidden (class = escondido; means hidden), even though I can see the link.
I'm learning to code, so I'm having a lot of trouble.
PS: I'm using selenium
I would like to make a vs code extension for that so a user presses a key combination than a text editor will open to the side where he could enter lines of text then whenever the text changes I would receive events with the changed text. Could you suggest to me how to open the editor if is it possible?
Thank you for taking the time to read the question.
Hope you have a great day ahead.
You can use showTextDocument and use ViewColumn.Beside to open the editor to the side of the currently active one:
https://code.visualstudio.com/api/references/vscode-api#window
You can listen for text doc changes with the onDidChangeTextDocument event:
https://code.visualstudio.com/api/references/vscode-api#workspace
Here's info on creating a command to open the preview window.
https://code.visualstudio.com/api/references/vscode-api#commands
I recently discovered the blissful convenience of being able to use the File, Save command from within the VBA Editor window to save the currently attached template without having to actually be in the template or close out of Word.
I thought it would be nice to have this command available on a Ribbon Tab or the QAT or even a keyboard shortcut, so I first added the Save Template command to a Ribbon Tab. But when I clicked on the tab, nothing happened.
I thought perhaps I needed to tweak things a bit with a macro, so I recorded a macro and clicked on the command, to see what the VBA statement would look like.
It looks simple and straightforward enough, very similar to a bazillion other "ActiveDocument" macros I have stored that run without any issues:
ActiveDocument.AttachedTemplate.Document.Save
But when I run the macro, I get the standard "Runtime error" message, with no hint as to what is wrong.
I cannot find any documentation regarding this command in any of my source material or anywhere on Google, nor can I find any discussions about it.
Any ideas what's missing here? Thanks in advance!
As I discovered, and Cindy Meister confirmed, the following works:
ActiveDocument.AttachedTemplate.Save
It will work even if the template is closed. The version that you got from the Macro Recorder, ActiveDocument.AttachedTemplate.Document.Save works only if the template is open. The version above works whether it's open or not. I don't program much in Word, but it looks like a template's Document object/property is instantiated when the template is opened and otherwise is nothing.