I want to use SikuliIntegrator in C#.
I run VS as administrator, install SikuliIntegrator throught NuGet manager and want to test him on simple task.
Heres my code
using SikuliModule;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SikuliTrainingNet
{
class Program
{
static void Main(string[] args)
{
string MyPicture = #"c:\111\Sik\MyPicture.png";
SikuliAction.Click(MyPicture);
}
}
}
after running code (and have prepared MyPicture on screen), all i get is exception "###FAILURE" any idea why?
I dont wanna use Sikuli4Net, becose its look like it work on web aps and I need just few simple clicks on desktop aplication.
I try sikuli in Java, and there it works with no problem. But I need to make my program in C#.
I Used This Code For Sikuli4Net in C#,It Was Working For Me First You need add the References please see this link for Reference
http://interviews.ga/angularjs/sikulic/
static void Main(string[] args)
{
APILauncher launch = new APILauncher(true);
Pattern image1 = new Pattern(#"C:\Users\Ramesh\Desktop\Images\userName.png");
Pattern image2 = new Pattern(#"C:\Users\Ramesh\Desktop\Images\password.png");
Pattern image3 = new Pattern(#"C:\Users\Ramesh\Desktop\Images\Login.png");
launch.Start();
IWebDriver driver = new ChromeDriver();
driver.Manage().Window.Maximize();
driver.Url = "http://gmail.com";
Screen scr = new Screen();
scr.Type(image1, "abc#gmail.com", KeyModifier.NONE);
scr.Type(image2, "12345", KeyModifier.NONE);
scr.Click(image3, true);
Console.ReadLine();
}
I used this code and it was working fine. First you should open the webpage on which you want to click and then give a path of the image(it should be a part of the webpage)
here is my code:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SikuliModule;
using OpenQA.Selenium;
namespace WordPressAutomation.DifferentTests
{
[TestClass]
public class Sikuli
{
[TestMethod]
public void TestMethod1()
{
driver.Initialize();
driver.instance.Navigate().GoToUrl("https://www.google.co.in");
SikuliAction.Click("E:/img.png");
}
}
}
To use SikuliInyegrator, you need to check the execution results in these files:
C:\SikuliExceptionLog.txt
C:\SikuliOutputLog.txt
Also you need to:
Have installed JRE7 or superior
Have environment variable PATH with the location of the bin folder
See installed in your “control panel > program and features> visual C++ 2010 Redistributable Package” at x86 and x64 bits according to your java JRE runtime platform. If not, then download and install the Redistributable Package form Microsoft site.
Related
I'm trying to establish connection to Azure DataExplorer cluster using C# ..
I referenced the C# in https://learn.microsoft.com/en-us/azure/kusto/api/netfx/about-kusto-data
and installed nuget package kusto.data in visual studio and copied the code and did dotnet run in cmd prompt, but it didn't work.
Below is my code-
using Microsoft.Azure.Management.Kusto;
using System;
namespace LensDashboradOptimization
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
//var clusterUrl = "https://masvaas.kusto.windows.net";
//var kcsb = new Kusto.Data.KustoConnectionStringBuilder(clusterUrl);
//Console.WriteLine(kcsb);
// Read the first row from reader -- it's 0'th column is the count of records in MyTable
// Don't forget to dispose of reader when done.
var client = Kusto.Data.Net.Client.KustoClientFactory.CreateCslQueryProvider("https://masvaas.windows.net/Samples;Fed=true");
var reader = client.ExecuteQuery("MyTable | count");
Console.WriteLine(reader);
}
}
}
I tried both fed=true and WithAadUserPromptAuthentication(); both didn't work. Am I missing something?
Hello and welcome to Stack Overflow!
I tried and faced a similar error when I was checking this out. But the issue turned out to be with the version of .Net Framework that I was running. The Kusto.Data package requires .Net Framework 4.6.2 as a dependency. When I had that installed, I was able to install and import the package, and also subsequently connect to the intended Kusto cluster and read data. This is the snippet that worked for me:
using System;
using Kusto.Data;
namespace hello_world
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
var client = Kusto.Data.Net.Client.KustoClientFactory.CreateCslQueryProvider("https://help.kusto.windows.net/Samples;Fed=true");
var reader = client.ExecuteQuery("StormEvents | sort by StartTime desc | take 10");
}
}
}
Please double check on the dependencies and let me know if you still run into issues. Hope this helps!
using Kusto.Data;
using Kusto.Data.Common;
using Kusto.Data.Net.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Only these using statement do the job that you are trying to. For that all you need to install SDK from nuget gallery .
Also, only install Microsoft.Azure.Kusto.Data and Microsoft.Azure.Management.Kusto from above. That is sufficient.
Hope this help.
Few more things you can look on as: 1) Static IP 2)VS 2019 community edition with Azure dev packages installed
WithAadUserPromptAuthentication, this method is not supported now as kusto database first need authentication for the user. and the console application is not able to open a prompt window. I recommend to use a web application.
I'm using VS 2015 community. My Selenium C# test case always runs twice. The Test Case Explorer window shows 1 test case was run but the pass result shows two of the same test cases were executed.
What is wrong with my test or framework?
I have created a Test File with testcase (NunitDemo.cs) under my project.
I attached a screenshot to my Solutions Explorer window as well.
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
namespace DemoNunit
{
[TestFixture]
public class NunitDemo
{
private IWebDriver driver;
[Test]
public void tc_newAccount()
{
//open browser and navigate to aut
driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.trainingrite.net");
//click on signup button
driver.FindElement(By.CssSelector("input.submitbtn")).Click();
//enter firstname, lastname, email, password
driver.FindElement(By.Id("ctl00_MainContent_txtFirstName")).Clear();
driver.FindElement(By.Id("ctl00_MainContent_txtFirstName")).SendKeys("Ren");
driver.FindElement(By.Id("ctl00_MainContent_txtLastName")).Clear();
driver.FindElement(By.Id("ctl00_MainContent_txtLastName")).SendKeys("G");
driver.FindElement(By.Id("ctl00_MainContent_txtEmail")).Clear();
driver.FindElement(By.Id("ctl00_MainContent_txtEmail")).SendKeys("rmng3#yahoo.com");
driver.FindElement(By.Id("ctl00_MainContent_txtPassword")).Clear();
driver.FindElement(By.Id("ctl00_MainContent_txtPassword")).SendKeys("12345");
driver.FindElement(By.Id("ctl00_MainContent_txtVerifyPassword")).Clear();
driver.FindElement(By.Id("ctl00_MainContent_txtVerifyPassword")).SendKeys("12345");
driver.FindElement(By.Id("ctl00_MainContent_txtHomePhone")).Clear();
driver.FindElement(By.Id("ctl00_MainContent_txtHomePhone")).SendKeys("951-265-1234");
driver.FindElement(By.Id("ctl00_MainContent_txtCellPhone")).Clear();
driver.FindElement(By.Id("ctl00_MainContent_txtCellPhone")).SendKeys("760-855-1234");
driver.FindElement(By.Id("ctl00_MainContent_txtInstructions")).Clear();
driver.FindElement(By.Id("ctl00_MainContent_txtInstructions")).SendKeys("Running first selenium automation scripts in C#!");
//click on submit button
driver.FindElement(By.Id("ctl00_MainContent_btnSubmit")).Click();
//verify new customer is added successfully
Assert.AreEqual("Customer information added successfully", driver.FindElement(By.Id("ctl00_MainContent_lblTransactionResult")).Text);
}
}
}
Do you have both the Nunit 2.x and 3.x Test Adapter installed in VS? If so try removing one of them and running the test.
As an addition to Dmitry's answer, if you have the NUnitTestAdapter installed via the Extensions as well as via the NuGet package, the tests will run twice. This is a known issue.
I trying to get my GPS position from a Desktop app, using Windows Runtime, in C#.
I followed this how-to to set up Visual Studio and this code sample to create the following trivial code as a C# console app :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using System.Runtime;
using System.Windows;
using Windows;
using Windows.Devices.Geolocation;
using Windows.Foundation;
using Windows.Foundation.Collections;
namespace GeoLocCS
{
public sealed partial class Program
{
static void Main(string[] args)
{
Test test = new Test();
Console.Read();
}
}
public class Test
{
private Geolocator geolocator;
public Test()
{
Console.WriteLine("test");
geolocator = new Geolocator();
this.getPos();
}
async void getPos()
{
Geoposition pos = await geolocator.GetGeopositionAsync();
Console.WriteLine(pos.Coordinate.Latitude.ToString());
}
}
}
When trying to compile, I get the error :
Error 1 'await' requires that the type 'Windows.Foundation.IAsyncOperation<Windows.Devices.Geolocation.Geoposition>' have a suitable GetAwaiter method. Are you missing a using directive for 'System'?
I tried to reference every DLL that I could, like "System.runtime", "System.Runtime.WindowsRuntime", "Windows.Foundation"...
What I am missing ?
Thanks for the answer,
Serge
I finally figured out my problem :
I am on 8.1 so I changed this in the .csproj file (targetingPlatform) instead of targeting 8.0
After that modification, I could reference "Windows"
I manually referenced the two following DLLs :
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\Facades\System.Runtime.dll
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Runtime.WindowsRuntime.dll
If you are On Win8.1 Please Use:
<TargetPlatformVersion>8.1</TargetPlatformVersion>
and not 8.0.
Adding to the existing answers:
I suddenly got this problem with a multiproject solution in WPF (still don't know why). I tried switching between TargetPlatformVersions 8.1 and 10.0, tried using the v4.5- and v4.5.1-System.Runtime.WindowsRuntime.dll, always alternating between BadImageFormatException and FileNotFoundException.
Turned out to be references in some of the app.config-files (not the .csproj-files!). Visual Studio 2017 must have added them at some point and as soon as I removed these entries, the above solutions finally worked.
I have almost searched every forum/website related to Selenium WebDriver but still unable to find the solution that how to user Assertions and Verifications in Selenium WebDriver using C#.
Here is my code where I just want to put a sample assertion in the code written below.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
namespace Healthfleet
{
class Login
{
static void Main(string[] args)
{
IWebDriver driver = new ChromeDriver(#"D:\Downloads");
driver.Navigate().GoToUrl("https://test.com/");
IWebElement username = driver.FindElement(By.Id("username"));
IWebElement password = driver.FindElement(By.Id("password"));
username.SendKeys("test#test.test");
password.SendKeys("test");
IWebElement loginButton = driver.FindElement(By.Id("Login"));
loginButton.Click();
}
}
}
I need to check if username = test or not by using assertion but I am unable to find any Assert class or method.
Am I missing some namespace which contains the Assert class or any other idea?
NUnit was required to test this. And you have to add its dll and then add namespace as
using NUnit.Framework;
Currently you've written the program that manages the browser. If you'll add assertion's from NUnit - it will throw an exceptions in case of failure.
If you want to create tests you should create class without static void Main(string[] args) but add some methods marked with [Test].
I would recommend you to learn the concepts of xUnit-systems and NUnit in particular.
I am trying to get the SuperSocketServer app up an running. However, I cannot seem to create an instance of the server. Here is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SuperSocket.SocketBase;
using SuperSocket.SocketBase.Config;
using SuperSocket.SocketEngine;
using SuperSocket.SocketBase.Protocol;
namespace WinnieServer
{
class Program
{
AppServer W = new AppServer();
static void Main(string[] args)
{
Console.Write("Starting...");
while (true)
{
}
}
}
}
I tried the examples in the source code. However, they all give the same error:
Cannot create an instance of the abstract class or interface 'SuperSocket.SocketBase.AppServer'
Is this the correct way to create an instance of SSS?
take care,
lee
I had this same issue. The download on their home screen gives you the 1.4.4 version. If you look in object explorer it IS abstract. If you go to their downloads and grab the binaries zip, you'll get the 1.5 version that ISN'T abstract.