Developed a WPF application in C# using selenium web driver. Given the IEdrive path as follows and it works fine.
driver = new InternetExplorerDriver(#"E:\AG\myGateway\myGateway_FF\driver");
But when I given the path like below
driver = new InternetExplorerDriver(#"http:\10.200.0.86\drivers");
then the following error throws out.
The file http:\10.200.0.86\drivers\IEDriverServer.exe does not exist.
Because I need to publish the WPF in my localhost. Please help me out.
For this, I have followed the below steps.
1.Created a new directory in the client system.
private static string _localpath = #"D:\Gateway\Drivers\";
System.IO.Directory.CreateDirectory(_localpath);
2.Then separately downloaded the driver and stored in the local path under directory which was created in the first step.
private static string _IEdriverpath = "http://10.200.0.86/Drivers/IEDriverServer.exe";
private static string _localpathIE = #"D:\Gateway\Drivers\IEDriverServer.exe";
wc.DownloadFile(_IEdriverpath, _localpathIE);
3.Finally executed the selenium command
driver = new InternetExplorerDriver(_localpath);
Related
My project was working fine, I didn't do anything in the code and after a few days the same code showed an error on console that is attached below Console Image
and my code side is attached below
string webUrl = "https://www.facebook.com/";
var options = new ChromeOptions()
{
BinaryLocation = #"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe",
AcceptInsecureCertificates = true
};
IWebDriver driver = new ChromeDriver(#"C:\Drive\Projects\Web-Scraping-Fb-messenger-master1\Web-Scraping-Fb-messenger-master\Web Scarpping\Classes", options);
driver.Navigate().GoToUrl(webUrl);
var element = driver.FindElement(By.Id("email"));
element.SendKeys("myemail");
element = driver.FindElement(By.Id("pass"));
element.SendKeys("mypassword");
element = driver.FindElement(By.XPath("//input[#value='Log In']"));
element.Click();
string link = string.Empty;
string grpname = string.Empty;
and on debugging it shows a selenium timeout error.
So my question is, how can I resolve the error:
ERROR:wmi_refresher.cc(129)] Unable to add the Win32_PerfRawData_PerfDisk_PhysicalDisk enum
Chrome Browser Version : 78.0.3904.108
Chrome Driver Version : 78.0.3904.105
Win32_PerfRawData_PerfDisk_PhysicalDisk Class
The Win32_PerfRawData_PerfDisk_PhysicalDisk raw performance data class provides raw data from performance counters that monitor hard or fixed disk drives on a computer where disks are used to store file, program, and paging data and are read to retrieve these items, and written to record changes to them.
As per this article this error:
ERROR:wmi_refresher.cc(129)] Unable to add the Win32_PerfRawData_PerfDisk_PhysicalDisk enum.
may occur during due to either of the following factors:
An invalid path.
Invalid characters in the path.
Syntax formatting of the path.
A valid path on SAN drives of a Failover Cluster.
This usecase
Your code trial was near perfect. However while passing the absolute path of the ChromeDriver you need to add the name of the WebDriver variant as well i.e. chromedriver. So effectively the line of code will be:
IWebDriver driver = new ChromeDriver(#"C:\Drive\Projects\Web-Scraping-Fb-messenger-master1\Web-Scraping-Fb-messenger-master\Web Scarpping\Classes\chromedriver", options);
I'm trying to use the dll version of ghost script in an azure web app. It has worked before, but now I start getting these errors when using Ghostscript.
An error occured when call to 'gsapi_new_instance' is made: -100
I'm using Ghostscript.NET for working with Ghostscript.
From reading other posts here, it could be because of missing permissions. But I'm not sure which permissions I'm missing.
According to your description, I have created a test demo using Ghostscript.NET with "gsdll32.dll" and published the application to azure. It works well(I don't change any setting).
As you said, it worked well before. I think this error is not related with your permissions. I suggest you could follow below step to troubleshoot the application.
1.Use remote debug to check the gsdll32.dll path is right in your application code
2.Create a new app web app and published the application to it and test again.
More details about my test codes, you could refer to below:
GhostscriptVersionInfo gvi = new GhostscriptVersionInfo(Server.MapPath("~/dll/gsdll32.dll"));
GhostscriptProcessor proc = new GhostscriptProcessor(gvi);
string inputFile = Server.MapPath("~/File/Test Document.pdf");
string outputFile = Server.MapPath("~/File/page-%03d.png");
int pageFrom = 1;
int pageTo = 2;
List<string> switches = new List<string>();
switches.Add("-empty");
switches.Add("-dSAFER");
switches.Add("-dBATCH");
switches.Add("-dNOPAUSE");
switches.Add("-dNOPROMPT");
switches.Add("-dFirstPage=" + pageFrom.ToString());
switches.Add("-dLastPage=" + pageTo.ToString());
switches.Add("-sDEVICE=png16m");
switches.Add("-r96");
switches.Add("-dTextAlphaBits=4");
switches.Add("-dGraphicsAlphaBits=4");
switches.Add(#"-sOutputFile=" + outputFile);
switches.Add(#"-f");
switches.Add(inputFile);
proc.Process(switches.ToArray());
Result:
My basic problem was converting a .docx file to .pdf. The problem would be solved incase I was allowed to use Microsoft.Office.Interop.Word.dll, which i am not since the server will not have MS Office installed. So I needed a free/open-source library that would allow me to do so. And i came across docx4j.NET.
http://www.docx4java.org/blog/2014/09/docx-to-pdf-in-c-net/
This worked fine as long as I ran it as a Console App. The following is the concerned code snippet:
string fileIN = #"C:\Users\...\Visual Studio 2013\Projects\HRDapp\HRDapp\Letter_Templates\AP.docx";
string fileOUT = #"C:\Users\...\Visual Studio 2013\Projects\HRDapp\HRDapp\Letter_Templates\AP.pdf";
log.Info("Hello from Common Logging");
// Necessary, if slf4j-api and slf4j-NetCommonLogging are separate DLLs
ikvm.runtime.Startup.addBootClassPathAssembly(
System.Reflection.Assembly.GetAssembly(
typeof(org.slf4j.impl.StaticLoggerBinder)));
// Configure to find docx4j.properties
// .. add as URL the dir containing docx4j.properties (not the file itself!)
Plutext.PropertiesConfigurator.setDocx4jPropertiesDir(projectDir + #"src\samples\resources\");
java.io.File file = new java.io.File(fileIN);
// OK, do it..
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(file);
java.io.FileOutputStream fos = new java.io.FileOutputStream(new java.io.File(fileOUT));
org.docx4j.Docx4J.toPDF(wordMLPackage, fos);
fos.close();
In case of using this in a Web App, the code runs fine till
java.io.File file = new java.io.File(fileIN);
and gets stuck at
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(file);
Although the file path is correct and works fine in the console app, but there seems something else that I am missing here. The log also prints upto the following statement-
iisexpress.exe Information: 0 : [INFO] org.docx4j.jaxb.Context - Using Java 6/7 JAXB implementation
.. and stops. Any kind of reply directing me to the source of the error will be very helpful. Thanks.
As Jeroen (of IKVM fame) has explained, when there is no main assembly (eg in an ASP.NET application), the IKVM class loader can't find your assembly when the code is trying to dynamically load a class.
So you'll want to add not just:
ikvm.runtime.Startup.addBootClassPathAssembly(
System.Reflection.Assembly.GetAssembly(
typeof(org.slf4j.impl.StaticLoggerBinder)));
but also:
ikvm.runtime.Startup.addBootClassPathAssembly(
System.Reflection.Assembly.GetAssembly(
typeof(org.slf4j.LoggerFactory)));
ikvm.runtime.Startup.addBootClassPathAssembly(
System.Reflection.Assembly.GetAssembly(
typeof(org.docx4j.jaxb.Context)));
I'm trying to set up an installer to register a web site. Currently, I've got it creating an Application Pool and Web Site under Windows Server 2003. Unfortunately, whenever I try to modify the ServerBindings property to set the IP Address, it throws an exception at me. I first tried this because the documentation here told me to http://msdn.microsoft.com/en-us/library/ms525712%28VS.90%29.aspx. I'm currently using VB.NET, but C# answers are okay too as I need to switch it over to using C# anyway.
siteRootDE.Properties.Item("ServerBindings").Item(0) = "<address>"
This throws an ArgumentOutOfRangeException. I checked it, and server bindings is of size 0. When I tried to create a new entry in the list like this:
siteRootDE.Properties.Item("ServerBindings").Add("<address>")
I get a COMException when I try that.
I looked at the registered property keys, and ServerBindings is nowhere to be found. However, when I create the Web Site through IIS, it generates ServerBindings correctly and I can see it.
What do I need to do to get ServerBindings to appear?
EDIT: I moved the code over to C# and tried it. It seems for some reason, VB.NET crashes when given either the above, but C# doesn't. But that code still doesn't seem to do anything. It just silently fails. I'm trying it like this:
// WebPage is the folder where I created the website
DirectoryEntry siteRootDE = new DirectoryRoot("IIS://LocalHost/W3SVC/WebPage");
// www.mydomain.com is one of the IP addresses that shows up
// when I used the IIS administrative program
siteRootDE.Properties["ServerBindings"].Value = ":80:www.mydomain.com";
siteRootDE.CommitChanges();
In C# you should be able to do this:
webSite.Invoke("Put", "ServerBindings", ":80:www.mydomain.com");
or
webSite.Properties["ServerBindings"].Value = ":80:www.mydomain.com";
EDIT:
Here is the sample code I used.
public static void CreateNewWebSite(string siteID, string hostname)
{
DirectoryEntry webService = new DirectoryEntry("IIS://LOCALHOST/W3SVC");
DirectoryEntry website = new DirectoryEntry();
website = webService.Children.Add(siteID, "IIsWebServer");
website.CommitChanges();
website.Invoke("Put", "ServerBindings", ":80:" + hostname);
// Or website.Properties["ServerBindings"].Value = ":80:" + hostname;
website.Properties["ServerState"].Value = 2;
website.Properties["ServerComment"].Value = hostname;
website.CommitChanges();
DirectoryEntry rootDir = website.Children.Add("ROOT", "IIsWebVirtualDir");
rootDir.CommitChanges();
rootDir.Properties["AppIsolated"].Value = 2;
rootDir.Properties["Path"].Value = #"C:\Inetpub\wwwroot\MyRootDir";
rootDir.Properties["AuthFlags"].Value = 5;
rootDir.Properties["AccessFlags"].Value = 513;
rootDir.CommitChanges();
website.CommitChanges();
webService.CommitChanges();
}
Also, here is a good article for reference.
I'm using Selenium RC + .Net Client Driver. I've created a Firefox profile in my c:\selenium\ directory. Here's my code:
Dim MySelenium As ISelenium = Nothing
MySelenium = New DefaultSelenium("localhost", 4444, "*custom C:/Program Files/Mozilla Firefox/firefox.exe -profile c:/selenium/", "http://www.google.com/")
When I run this, I get the following error:
Failed to start new browser session: Error while launching browser
What is the proper way to do this?
You need to launch it via RC rather than in your code.
So you would do
java -jar selenium-server.jar -firefoxProfileTemplate c:\selenium\
to launch the browser and then do
Dim MySelenium As ISelenium = Nothing
MySelenium = New DefaultSelenium("localhost", 4444, "*firefox", "http://www.google.com/")
and that should launch Firefox for with the profile you want.
In Java you can create the Selenium Server programmatically and pass a File as the newFirefoxProfileTemplate configuration property:
RemoteControlConfiguration rcc = new RemoteControlConfiguration();
rcc.setPort(5499);
rcc.setFirefoxProfileTemplate(newFirefoxProfileTemplate); // This is a File object
SeleniumServer server = new SeleniumServer(rcc);
server.start();
Perhaps there are similar (or the same) vb.net classes available.