The new geckodriver v0.17.0 has a new way to install addons as mentioned here:
POST /session/{session id}/window/fullscreen to invoke the window manager-specific full screen operation
POST /session/{session id}/moz/addon/install to install an extension [Gecko only]
POST /session/{session id}/moz/addon/uninstall to uninstall an extension [Gecko only]
How can I use these endpoints to install my addon to firefox for my selenium tests?
You have to know the ip and port in which geckodriver starts. And Once the geckodriver started you can get the Session Id from the driver Instance.
You can get the Ip Address and Port as mentioned here
For ex: if the ip and port is
localhost:15874
and session id is 1e53412a-05eb-40a9-8a7b-bb8dd6fd75ab
Then you can post a json message to
http://localhost:15874/session/1e53412a-05eb-40a9-8a7b-bb8dd6fd75ab/moz/addon/install
The body of post message should be
{
"path":"xxyy.xpi",
"temporary":true
}
In case somebody need to use this from .NET client
(as it is not yet implemented)
Public Class MyFirefoxDriver
Inherits OpenQA.Selenium.Firefox.FirefoxDriver
Public Sub New(fo As OpenQA.Selenium.Firefox.FirefoxOptions)
MyBase.New(fo)
MyBase.CommandExecutor.CommandInfoRepository.TryAddCommand("moz-install-web-ext", New CommandInfo(CommandInfo.PostCommand, "/session/{sessionId}/moz/addon/install"))
End Sub
Public Sub InstallWebExtension(path As String)
Dim params As New Dictionary(Of String, Object)
params.Add("path", path)
params.Add("temporary", True)
MyBase.Execute("moz-install-web-ext", params)
End Sub
End Class
Related
I have an app which will download publicly available data as a string from a website.
The below code on a WinForm app on Windows 10 works perfectly, but it doesn't work at all on Windows Server 2019.
I have tried enabling the "Allow App Through Firewall" option & have also tried allowing the program in outbound rules in the firewall, but nothing is working.
What is the issue?
Private Async Function Run_WebRequest(URL As String) As Task(Of String)
Try
Dim client As WebClient = New WebClient()
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
client.Headers.Add("scheme", "https")
client.Headers.Add("accept-language", "en-US, en;q=0.9, ml;q=0.8")
Dim Response = client.DownloadString(URL)
Return Response
Catch ex As Exception
Return ex.ToString
End Try
End Function
I missed to add that this is a Virtual Private Server OS Windows Server 2019 from Contabo hosting services
Please see below screenshot of the app which is a standalone exe file with three buttons having different Webclients for testing, none of them works on
I am trying to hook up Swagger to a VB.Net REST API project. No matter what I try the app continues to return a 404 response when hitting the swagger/ui/index URL. Initially, on start-up I enter the following URL: http://localhost/ApiNameHere/Swagger.
IIS attempts to access (redirects to) http://localhost/swagger/ui/index. This returns a 404 response.
Swashbuckle was used to install Swagger
Locally, the app runs in IIS.
I have seen recommendations to delete the .vs folder. I have tried that, to no avail.
Here is the SwaggerConfig.vb file:
Public Class SwaggerConfig
Public Shared Sub Register(config As HttpConfiguration)
Dim thisAssembly = GetType(SwaggerConfig).Assembly
config.EnableSwagger(
Sub(c)
c.SingleApiVersion("v1", "ApiNameHere")
End Sub
).EnableSwaggerUi()
End Sub
End Class
Here is the relevant Startup.vb code :
Dim config = New HttpConfiguration()
config.MapHttpAttributeRoutes()
config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}", New With {RouteParameter.Optional})
SwaggerConfig.Register(config)
app.UseWebApi(config)
Any thoughts?
I'm trying to make a function to download images from a server and use them in a picturebox and if needed save it locally. Right now I'm using:
Public Function WebImgDownload(ByVal Url As String, Optional ByVal saveFile As Boolean = False, Optional ByVal location As String = "C:\") As Image
Dim client As New WebClient With {
.Credentials = New NetworkCredential("username", "password")}
Dim bytes() As Byte = client.DownloadData(Url)
Dim stream As New IO.MemoryStream(bytes)
If saveFile Then My.Computer.FileSystem.WriteAllBytes(location, bytes, False)
Return New Bitmap(stream)
End Function
Now this all works fine when I use the function like:
PictureBox1.Image = WebImgDownload("myurl")
But it only works when I provide world permissions to the folder on cPanel. If I only provide user permission to the folder so it will require authentication and use my credentials it responds with a 404 error message.
I'm using the user and password I login to the server but it just throws the error:
System.Net.WebException: 'The remote server returned an error: (404) Not Found.'
Is there something I'm missing?
Thanks in advance!
So I found my error. I was trying to authenticate by just using the normal address when I needed to use the ftp address for the file. In my case I was using:
https://myserver/folder/file.jpg
Now instead I used the ftp address like this:
ftp://myserver/public_html/folder/file.jpg
That way it authenticates correctly and points to the file correctly too because not using the public_html in the address was pointing it to the wrong folder.
For some reason when you dont need to authenticate with the server you can just use the normal address when the file is public.
I want to switch from Jsch to Apache Mina to query remote Linux hosts and to get the few tasks done.
I need to achieve things like list files of a remote host, change directory, get file contents, put a file into the remote host etc.,
I am able to successfully connect and execute a few shell commands using session.executeRemoteCommand().
public byte[] getRemoteFileContent(String argDirectory, String fileName)
throws SftpException, IOException {
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
StringBuilder cmdBuilder = new StringBuilder("cat" + SPACE + remoteHomeDirectory);
cmdBuilder.append(argDirectory);
cmdBuilder.append(fileName);
_session.executeRemoteCommand(cmdBuilder.toString(), stdout, null, null);
return stdout.toByteArray();
}
public void connect()
throws IOException {
_client = SshClient.setUpDefaultClient();
_client.start();
ConnectFuture connectFuture = _client.connect(_username, _host, portNumber);
connectFuture.await();
_session = connectFuture.getSession();
shellChannel = _session.createShellChannel();
_session.addPasswordIdentity(_password);
// TODO : fix timeout
_session.auth().verify(Integer.MAX_VALUE);
_channel.waitFor(ccEvents, 200);
}
I have the following questions,
How can I send a ZIP file to a remote host much easily in API level (not the Shell commands level)? And all other operations in API level.
Can I secure a connection between my localhost and remote through a certificate?
As of now, I am using SSHD-CORE and SSHD-COMMON version 2.2.0. Are these libraries enough or do I need to include any other libraries?
executeRemoteCommand() is stateless how can I maintain a state?
I needed sshd-sftp and its APIs to get the file transfer work.
Below code gets the proper API,
sftpClient = SftpClientFactory.instance().createSftpClient(clientSession);
On sftpClinet I called read() and write() methods get the task done. This answers my question fully.
I have following vb code to connect scanner via WIA in a Windows form application.
Private Function Connect() As Device
Dim WiaDev As Device = Nothing
Dim manager As New DeviceManager()
Try
For Each info As DeviceInfo In manager.DeviceInfos
If info.DeviceID = DeviceID Then
WiaDev = info.Connect()
Return WiaDev
End If
Next
Throw New Exception(ex.Message)
End Try
End Function
It works fine in local. But in virtual machine it throws following exception while executing the line info.Connect(). Exception =>
"Error HRESULT E_FAIL has been returned from a call to a COM component". It will be nice if anybody suggest some solution. Thanks :)
I found solution that , it is necessary to install corresponding scanner driver in both local and virtual machine.