Pasting copied clipboard content in remote execution - selenium

I am clicking a button which copies a URL and I need to navigate to that URL in a new tab. In remote session I don't see anything being copied and navigating to a blank page. Below is the code snippet I am using:
Toolkit toolkit = Toolkit.getDefaultToolkit();
Clipboard clipboard = toolkit.getSystemClipboard();
String linkCopied = (String) clipboard.getData(DataFlavor.stringFlavor);
This works fine in local execution, but in remote execution this is not copying anything. Any help here?

Related

VBA IE 10 Automation - Automatically Save PDFs

I'm trying to automate the process of saving PDF invoices for bookkeeping purposes. The method suggested here does not work because a login is required to access the invoices.
I currently have a macro that navigates to the page, logs in and opens the links to each invoice. The URL scheme for these invoices is .../account/invoice/?invoice_number=XXXXXX. Navigating to each of these URL brings up the files in the
window. I would like the files to automatically save, but according to this page, the Always ask before opening this type of file option was depreciated from IE 10 and 11 due to security reasons.
I attempted to automatically click Save using this method, but the code here seems to be for a different version of IE.
The line:
hWnd = FindWindow("#32770", "File Download")
was modified to:
hwnd = FindWindow("#32770", "View Downloads - Windows Internet Explorer")
This successfully captures the download window, but it fails to find the &Save button for me to click. My guess would be that it's because there are multiple save buttons.
Any ideas would be greatly appreciated! Thanks.

How to say OK to all the popups in excel by using vba

I am trying to open some files in a specific web page by the following hyperlink which is saved in a specific cell. While executing the below-mentioned line (hyperlink.follow) I am getting warning ⚠ popup which I need to say ok.
I want to make this automate, please somebody help me
Worksheets(1).cells(2,1).hyperlinks.follow
I tried application.displayalerts = false/true before and after the line, but it doesn't work

Opening a url in a specific web browser when clicked - VB.net

I'm trying to figure out a way to have a specific web browser open (Internet Explorer for example) when a URL is clicked using VB.net
As I have it now, my code creates and sends out an email that displays a title and a hyperlink for the user to click on. Right now, the hyperlink opens the default browser, but I want to make it always open Internet Explorer.
The code below is what I have for displaying the Hyperlink. It displays "View Document" and the prints the hyperlink underneath. The hyperlink in this case is stored in my LinkLabel since its already part of the application somewhere else
What do I need to add to the code so that it defaults to Internet Explorer when it is clicked?
I have come across suggestion of using the full file path to Internet Explorer on the C: Would that work?
<a href=microsoft-edge:http://example.com>my link</a>
Update:
... & "my link" + ...

Documents.Add results in template being locked

I have a macro that creates a new document based on a template stored on a network share. This macro is stored in each user's Word\STARTUP folder as the file "macros.dotm" and is executed by a button added to a toolbar.
The template file gets locked as soon as the macro code is executed and stays locked so long as the derivative document is still open by another user.
It has no impact on their ability to open new documents based on the macro, but if I want to edit the template, I have to ask them to close Word (and hope nobody else goes into it).
Macro code:
Documents.Add Template:="F:\templates\letterhead.dotm", NewTemplate:=False, DocumentType:=0`
One way around this is detaching the document from the template after it is generated:
Dim doc As Document
Set doc = Documents.Add(Template:="F:\templates\letterhead.dotm", NewTemplate:=False, DocumentType:=0)
Set doc.AttachedTemplate = Nothing
Alternatively, change the filesystem permissions on the template so only you have write access.
The issue is that the template is on a network drive - this is a pretty common issue. One way to get around it is to have your calling template copy over that template locally first and then create a new doc based off of that (and then delete the template when done).

gwt-ext file upload

I am trying to do a file upload from gwt-ext without bringing up the dialog box. To do this, I created a FormPanel and added the appropriate fields to it. Then did a form.submit(). This doesn't seem to work. Any idea why? The code is shown below.
final FormPanel uploadForm = new FormPanel();
uploadForm.setVisible(false);
uploadForm.setFileUpload(true);
final TextField sourceFile = new TextField("File", "sourceFile");
sourceFile.setVisible(false);
sourceFile.setInputType("file");
sourceFile.setValue("/tmp/test.txt");
final TextField targetFile = new TextField("Upload As", "targetFile");
targetFile.setVisible(false);
targetFile.setValue("different.txt");
uploadForm.add(sourceFile);
uploadForm.add(targetFile);
final String url = GWT.getModuleBaseURL() + "/uploadFile";
uploadForm.getForm().submit(url, null, Connection.POST, null, false);
I tested the servlet on the server side with a simple html form and it works correctly. Only the GWT-EXT version doesn't seem to work.
I found out why the above piece of code is not working. The primary issue here is that file uploads are blocked by the browser due to security reasons if the upload form has not been rendered and/or if the form has been modified after the user clicks the submit button. If the browser did allow such things, then any file on the system can be easily uploaded without the user's knowledge.
Solution to to the above problem is to bring up the dialog box, do the upload in the event handler for the submit button and in the onActionComplete method of the form listener, do any other processing.
The whole idea of uploading without dialog box looks like a security breach to me. I can imagine an application that steals passwords file whenever opened, if only the above would be possible.