-
Notifications
You must be signed in to change notification settings - Fork 143
Winium Desktop C# example for file path
sheikhsamina edited this page Aug 30, 2018
·
1 revision
using System; using System.IO; using System.Linq; using System.Threading; using System.Xml; using WindowsInput; using WindowsInput.Native; using Winium.Cruciatus.Core;
namespace windows10automation {
public class Calculator
{
static InputSimulator s;
static void Main(string[] args)
{
try
{
var winFinder4 = Winium.Cruciatus.Core.By.Name("Running applications");
var win4 = Winium.Cruciatus.CruciatusFactory.Root.FindElement(winFinder4);
var winFinder2 = Winium.Cruciatus.Core.By.Name("Windows Explorer");
var win2 = Winium.Cruciatus.CruciatusFactory.Root.FindElement(winFinder2);
win2.Click();
var winFinder5 = Winium.Cruciatus.Core.By.Name("Libraries");
var win5 = Winium.Cruciatus.CruciatusFactory.Root.FindElement(winFinder5);
var winFinder3 = Winium.Cruciatus.Core.By.Uid("1001");
var win3 = Winium.Cruciatus.CruciatusFactory.Root.FindElement(winFinder3);
win3.SetText("C:\\DIS\\CCD_AutoExtraction\\Prime\\Family Tree");
// var winFinder6 = Winium.Cruciatus.Core.By.XPath("//*[@ClassName='ToolbarWindow32']");
//var win6 = Winium.Cruciatus.CruciatusFactory.Root.FindElement(winFinder6);
var winFinder7 = Winium.Cruciatus.Core.By.Uid("Item 100");
var win7 = Winium.Cruciatus.CruciatusFactory.Root.FindElement(winFinder7);
win7.Click();
s = new InputSimulator();
// s.Keyboard.KeyDown(VirtualKeyCode.CONTROL);
// s.Keyboard.KeyPress(VirtualKeyCode.VK_A);
// s.Keyboard.KeyUp(VirtualKeyCode.CONTROL);
s.Keyboard.KeyDown(VirtualKeyCode.CONTROL);
s.Keyboard.KeyPress(VirtualKeyCode.DOWN);
s.Keyboard.KeyPress(VirtualKeyCode.UP);
s.Keyboard.KeyUp(VirtualKeyCode.CONTROL);
for (int cnt = 1; cnt <= 7; cnt++)
{
s.Keyboard.KeyDown(VirtualKeyCode.SHIFT);
s.Keyboard.KeyPress(VirtualKeyCode.DOWN);
s.Keyboard.KeyPress(VirtualKeyCode.UP);
s.Keyboard.KeyPress(VirtualKeyCode.F10);
s.Keyboard.KeyUp(VirtualKeyCode.SHIFT);
Thread.Sleep(1000);
var winFinder8 = Winium.Cruciatus.Core.By.Uid("Item 6");
var win8 = Winium.Cruciatus.CruciatusFactory.Root.FindElement(winFinder8);
win8.Click();
var winFinder9 = Winium.Cruciatus.Core.By.Name("Notepad");
var win9 = Winium.Cruciatus.CruciatusFactory.Root.FindElement(winFinder9);
win9.Click();
s.Keyboard.KeyDown(VirtualKeyCode.CONTROL);
s.Keyboard.KeyPress(VirtualKeyCode.HOME);
s.Keyboard.KeyUp(VirtualKeyCode.CONTROL);
s.Keyboard.KeyPress(VirtualKeyCode.DELETE);
s.Keyboard.KeyPress(VirtualKeyCode.DELETE);
s.Keyboard.KeyDown(VirtualKeyCode.CONTROL);
s.Keyboard.KeyPress(VirtualKeyCode.VK_S);
s.Keyboard.KeyUp(VirtualKeyCode.CONTROL);
var winFinder19 = Winium.Cruciatus.Core.By.Name("Close");
var win19 = Winium.Cruciatus.CruciatusFactory.Root.FindElement(winFinder19);
win19.Click();
s.Keyboard.KeyPress(VirtualKeyCode.DOWN);
}
}
catch (Exception e)
{
Console.Write(e.Message);
}
}
}
}
package testcases; import java.net.MalformedURLException; import java.net.URL; import org.openqa.selenium.By; import org.openqa.selenium.winium.DesktopOptions; import org.openqa.selenium.winium.WiniumDriver public class calculator {
public static void main(String[] args) throws MalformedURLException, InterruptedException { DesktopOptions option = new DesktopOptions(); option.setApplicationPath("C:\\Windows\\System32\\calc.exe"); WiniumDriver driver = new WiniumDriver(new URL("http://localhost:9999"), option); Thread.sleep(5); driver.findElement(By.name("Five")).click(); driver.findElement(By.id("multiplyButton")).click(); driver.findElement(By.name("Six")).click(); driver.findElement(By.id("equalButton")).click();
} }