Giter Site home page Giter Site logo

winium.cruciatus's Introduction

English description | Описание на русском

Winium for Desktop

Build Status Inner Server NuGet downloads Inner Server NuGet version

Winium.Cruciatus is C# Framework for automated testing of Windows application based on WinFroms and WPF platforms

Winium.Cruciatus is an open source C# Framework for automated testing of Windows application based on WinFroms and WPF platforms.

Winium.Cruciatus is a wrapper over Microsoft UI Automation library in the System.Windows.Automation namespace.

Why Winium.Cruciatus?

  • Enough Visual Studio Professional offering
  • You can use any testing framework to write tests (example NUnit)

Quick Start

  1. Add reference to Winium.Cruciatus in UI test project (install NuGet package)

  2. Create a map application

  3. Use created map in tests

  4. Run your tests and watch the magic happening

Example

Very Quick Start

  1. Add reference to Winium.Cruciatus in UI test project (install NuGet package)

  2. Create C# Console Application project and use this code:

    namespace ConsoleApplication
    {
        using System.Windows.Automation;
        using Winium.Cruciatus.Core;
        using Winium.Cruciatus.Extensions;
    
        public class Program
        {
            private static void Main(string[] args)
            {
                var calc = new Winium.Cruciatus.Application("C:/windows/system32/calc.exe");
                calc.Start();
    
                var winFinder = By.Name("Calculator").AndType(ControlType.Window);
                var win = Winium.Cruciatus.CruciatusFactory.Root.FindElement(winFinder);
                var menu = win.FindElementByUid("MenuBar").ToMenu();
    
                menu.SelectItem("View$Scientific");
                menu.SelectItem("View$History");
    
                win.FindElementByUid("132").Click(); // 2
                win.FindElementByUid("93").Click(); // +
                win.FindElementByUid("134").Click(); // 4
                win.FindElementByUid("97").Click(); // ^
                win.FindElementByUid("138").Click(); // 8
                win.FindElementByUid("121").Click(); // =
    
                calc.Close();
            }
        }
    }
  3. Run ConsoleApplication and watch the magic happening

Contributing

Contributions are welcome!

  1. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug.
  2. Fork the repository to start making your changes to the master branch (or branch off of it).
  3. We recommend to write a test which shows that the bug was fixed or that the feature works as expected.
  4. Send a pull request and bug the maintainer until it gets merged and published. 😃

Contact

Have some questions? Found a bug? Create new issue or contact us at [email protected]

License

Winium is released under the MPL 2.0 license. See LICENSE for details.

winium.cruciatus's People

Contributors

csharpru avatar lionrouge avatar nickab avatar shiron avatar skyline-gleb avatar stoneman avatar tkurnosova avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

winium.cruciatus's Issues

Microsoft Windows Automation API 3.0

Research #47 showed:

  • UISpy used UIAutomation* references from .NET Framework (Cruciatus too)
  • VisualUIAVerify used UiaComWrapper (with Interop.UIAutomationClient) spreaded with Windows Kits or VisualStudio

Advantages of using UiaComWrapper:

  • Cruciatus sees the needed elements from #47

Disadvantages of using UiaComWrapper:

  • Control tree changed for some elements, for example, ComboBox in windows save as dialog
  • Many elements stopped to implement some automation patterns
  • Not included in .NET Framework (but may be project can help)

Needed changes for using UiaComWrapper in baddc0a commit. Or see draft/use-uiacomwrapper-lib branch.

ToolStripButton placed after ToolStripComboBox not found in WinForms app

Can't find button placed after ToolStripComboBox :(

Visual UI Automation Verify & Inspect tools shows both buttons in the tree :)
UISpy - does not show button2 :(

Test can't find button2 = menu.FindElementByName("btn 2");
Test code:
[TestMethod]
public void TestMethod2()
{
var app = new Winium.Cruciatus.Application(@"path to simple test application");
app.Start();

        var winFinder = By.Name("MainTestWindow").AndType(ControlType.Window);
        var win = Winium.Cruciatus.CruciatusFactory.Root.FindElement(winFinder);
        var menu = win.FindElementByUid("toolStrip1").ToMenu();
        var button1 = menu.FindElementByName("btn 1");
        button1.Click();
        var button2 = menu.FindElementByName("btn 2");
        button2.Click();


        app.Kill();
        //app.Close();
    }

Simple Test application code:
public class Form1 : Form
{
private ToolStrip toolStrip1;
private ToolStripButton button1;
private ToolStripButton button2;
private ToolStripComboBox drop1;

    public Form1()
    {
        InitializeComponent();
        this.Text = "MainTestWindow";
    }
    private void InitializeComponent()
    {
        toolStrip1 = new System.Windows.Forms.ToolStrip();
        toolStrip1.GripStyle = ToolStripGripStyle.Hidden; // no matter
        toolStrip1.Name = "toolStrip1";
        toolStrip1.Text = "toolStrip 1";
        button1 = new ToolStripButton("one 1");
        button1.Name = "btn1";
        button1.Text = "btn 1";
        button2 = new ToolStripButton("two 2");
        button2.Name = "btn2";
        button2.Text = "btn 2";
        drop1 = new ToolStripComboBox("combo1");
        drop1.Name = "drop1";
        // Add items to the ToolStrip.
        toolStrip1.Items.Insert(0, button1);
        toolStrip1.Items.Insert(1, drop1);
        toolStrip1.Items.Insert(2, button2);
        drop1.Visible = true; // if true test fails, if false - test passes            
        Controls.Add(toolStrip1);   
    }
}

Testing a browser URL opened from a Windows Application

So far i have tested my windows application through winium and now i have a scenario where i need to validate the URL which was opened on a browser from a button on windows application.

Is this currently possible to pass control from Win application to the launched browser using Winium?

Even if not, is there any other work around? Even if i can get just the URL i will open other instance of Selenium webdriver with that URL.

Unable to click on Subject field in MS Outlook 2016 application.

Trying to automate a new scenario where we open the Outlook application and follow below steps.

  1. Enter to email address.
  2. Enter subject.
  3. Enter email content.

Able to automate till Step 1 and Step 3. Only step 2 is not being identified. PFB the below source code. Tried all possible combinations for subject properties. Tried to find it using name - "Subject" and using class name and also automation id. But no luck. Kind of stuck and need help regarding the same.

Thank You.

package test;

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.io.IOException;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;

import Allocator.Allocator;

public class MSOutlook extends Allocator {

	public void openOutlook() throws InterruptedException, IOException {
		setupEnvironment("Outlook");
		Thread.sleep(10000);		
	}
	
	public void sampleOps() {
		driver.findElement(By.name("File Tab")).click();
		driver.findElement(By.name("Exit")).click();
	}
	
	public void sendEmail() throws InterruptedException, AWTException {
		driver.findElement(By.name("New Email")).click();
		Thread.sleep(2000);
		WebElement to = driver.findElement(By.name("To"));
		WebElement cc = driver.findElement(By.name("Cc"));
		WebElement sub = driver.findElement(By.className("Static"));
		to.sendKeys("[email protected]");
		sub.sendKeys("Subject");
			
		//Insert Subject
		driver.findElement(By.name("Page 1 content")).sendKeys("Test Email");
		driver.findElement(By.name("Send")).click();
		driver.close();
	}

	public static void main(String args[]) throws InterruptedException, IOException, AWTException {
		MSOutlook c = new MSOutlook();
		c.openOutlook();
		c.sendEmail();
	}

}

Cannot start wininum driver with selenium 4.9.1

I'm using latest winium driver but when upgrading selenium webdriver to latest version (4.9.1). There is an exception with winium : "Illegal key values seen in w3c capabilities".

My DesktopOptions:
{
DesktopOptions options = new DesktopOptions();
options.setDebugConnectToRunningApp(true);
}

Very Quick Start not working

I am trying to follow the steps in the "Very Quick Start". When I run ConsoleApplication, the calculator opens but nothing happens after that. Eventually, the test fails with an error that it cannot find View$Scientific.

Winium Checkbox Change Check State

I'm currently working on a test that needs to change the state of a checkbox from check to unchecked but can't seem to find a way to make the state change in the test.

I have tried the Cruciatus.Element.Extension Checkbox methods of Check() and Uncheck() but the action is not performed.

What am I missing to make this work?

Winium to identify objects using VBName

Hi,

I'm working on automating a native desktop application using Winium which has only VBName property as unique identifier. VBName property does not show up using Inspect or UI Spy tool but i was able to get it using UFT object Spy. We have tried below approach and none of them worked out

  1. Using VBName in xpath
  2. override the Winium methods to operate on VBObjects using unique property VbName,
  3. implement the VB environment methods and create our own driver to handle the VBObjects something like driver.findelement(By.vbname(""))

Let me know if there is any other approach i can try or is there some other way the driver can be customized to handle this. I appreciate any help in this regards.

Thanks,
Nivedita

Help me on how to get the list items using Cruciatus, i tried multiple ways but no luck, some ne please guide me

CruciatusElement accountFunctionControl = quest.FindElementByUid("SelectAccountFunctionControl");
accountFunctionControl = accountFunctionControl.FindElementByUid("displayBlock1");
accountFunctionControl = accountFunctionControl.FindElementByUid("displayBlockContentPanel1");
accountFunctionControl = accountFunctionControl.FindElementByUid("SearchDialog");

        CruciatusElement lookForControl = accountFunctionControl.FindElementByUid("4002");
        lookForControl.FindElementByUid("1001").SetText("#");

        accountFunctionControl.FindElementByUid("4006").ToComboBox().Expand();
        accountFunctionControl.FindElementByUid("4006").ToComboBox().FindElement(Winium.Cruciatus.Core.By.Name("Name")).Click();
        accountFunctionControl.FindElementByUid("1").Click();

        //ListBox listBox = accountFunctionControl.FindElementByUid("4004").ToListBox();

        Winium.Cruciatus.Elements.DataGrid grid = accountFunctionControl.FindElementByUid("4004").ToDataGrid();

        Winium.Cruciatus.Elements.ListBox list = accountFunctionControl.FindElementByUid("4004").ToListBox();

        var getValues = accountFunctionControl.FindElements(ByXPath.XPath(".//*[@AutomationId='4004']"));
        var getValues1 = accountFunctionControl.FindElements(Winium.Cruciatus.Core.By.XPath(".//*[@AutomationId='4004']"));

        var items=  list.FindElements(Winium.Cruciatus.Core.By.XPath("./*[contains(@LocalizedControlType, 'list item')]"));
        var grids = grid.FindElements(Winium.Cruciatus.Core.By.XPath("./*[contains(@LocalizedControlType, 'list item')]"));

        var items23 = list.FindElements(Winium.Cruciatus.Core.ByXPath.XPath("./*[contains(@LocalizedControlType, 'list item')]"));
        var grids23 = grid.FindElements(Winium.Cruciatus.Core.ByXPath.XPath("./*[contains(@LocalizedControlType, 'list item')]"));

        var getValues2 = accountFunctionControl.FindElements(ByXPath.XPath(".//*[@AutomationId='4004' and @LocalizedControlType='list item']"));

image

Расширить интерфейс IKeyboard

Методами ЗажатьКнопку, ОтжатьКнопку. Только необходимо определится в терминологии.. KeyDown/KeyUp или PressKey/ReleaseKey
У симулятора SendKeys невозможно реализовать данные методы, поэтому там будет NonImplementedException

FindElementByName does not identify all the elements with 'same name' under the tree

Hi I'm using Winium to test my application. The application has a navigation tab nad 4 elements witht he name "Worklists". One of them has the Control type button.
I used FindElement(By.Name("Worklists").AndType(ControlType.Button)) but, failed to identify the element.

I also used FindElementsByName("Worklists"). This line only captures the first three elemets and not the button.

Any idea how to navigate to the button element??

Below is the tree structure, worklist button attributes and snippet of C# code

worklist

worklistbutton

c snippet

not have ClickablePoint for my button

I have a button like

...
<Button Uid="refresh">
    <StackPanel>
        <icon/>
       <textblock/>
    </StackPanel>
</Button>
...

test code

...
Application medicine = new Application("path/to/my/program.exe");
medicine.Start("-m");
ByProperty winFinder = By.Uid("shell").AndType(ControlType.Window);
CruciatusElement win = CruciatusFactory.Root.FindElement(winFinder);

CruciatusElement btn = win.FindElementByUid("refresh");
btn.Click(MouseButton.Left);
btn.Click(MouseButton.Left);
...

test results

[14:36:08] [Debug] Element 'type: ControlType.Button, uid: refresh' not have ClickablePoint
[14:36:09] [Info] Click on 'type: ControlType.Button, uid: refresh' element at (-817.5, 272) BoundingRectangle center

Why cannot click it? My test project is .Net 4.6.2 and my program is .Net 4.0

Clicking on a button that closes the window may trigger an exception

Repro using the standard "FileOpenDialog":

  1. set the content of the address toolbar and filename combos to point to an existing file
  2. trigger a click on the "Open" button

Chances are the dialog closes fast enough for the Logger.Info(..._ calls in TryClick... methods in CruciatusCommands.cs to find a now-invalid Element, which will cause an exception while trying to format the message. In my case, it happened more often than not.

Suggestion: format the message in advance into a local variable before performing the click action, use the formatted message with Logger.Info after performing the click action.

Winium driver launching issue in Python

from selenium import webdriver

driver = webdriver.Remote(
command_executor='http://localhost:9999',
desired_capabilities={
"debugConnectToRunningApp": 'false',
"app": r"C:/windows/system32/calc.exe"

})

O/P > urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=9999): Max retries exceeded with url: /session (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x03DA4BF0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))

select Outlook element using Winium

Hi,
I want to automate some outlook process by using Winium, I need to click on emails in outlook.
but I can't find email by XPath. can't use name property it got frequently change for different systems.
Currently, I used this code also but no positive response.

const string XPath = ".//*[contains(@name, 'Subject Test Mail')]";
var toEmailFinder = Winium.Cruciatus.Core.By.XPath(XPath);
var toEmail = Winium.Cruciatus.CruciatusFactory.Root.FindElement(toEmailFinder);
toEmail.Click();

Проблема на билдсервере

И это возможно проблема метода в том числе. Суть - тест на GetFocusedElement падает если в этот момент на билдмашине открыта папка с выделенным элементом и тогда два варианта, либо приложение открывается за папкой и тычок действительно не в приложение происходит, либо возвращается не верный элемент (либо не успевает быть сфокусированным либо есть разные типы фокусов....)

Click coordinates differs in local VM vs Azure VM where OS remains same

I am getting a weird issue that my 2nd click coordinates differ on different machines.
Common Details:

  • Using Windows Server 2012 R2
  • Using Winium.Cruciatus only without WebDriver.
  • My local laptop resolution is 1920x1080

Case 1:
When running the utility in my local VM, it runs fine and the output snippet is-

Waiting for 5 seconds
Window Found : XYZ - Installation Wizard
FindElementByUid found : buttonInstallConsoles
[10:41:37] [Info] Click on 'type: ControlType.Button, uid: buttonInstallConsoles, name: PROCEED WITH INSTALL.' element at (634, 480) ClickablePoint
Waiting for 10 seconds
Window Found : XYZ Consoles - Installation Wizard
FindElementByUid found : 92
[10:41:47] [Info] Click on 'type: ControlType.Button, uid: 92, name: Next >' element at (798, 592) ClickablePoint
Waiting for 4 seconds

Case 2:
When running the utility in my Azure VM, the coordinates of 2nd click action (uid: 92, name: Next >) changes -

Waiting for 5 seconds
Window Found : XYZ - Installation Wizard
FindElementByUid found : buttonInstallConsoles
[18:48:28] [Info] Click on 'type: ControlType.Button, uid: buttonInstallConsoles, name: PROCEED WITH INSTALL.' element at (674, 499) ClickablePoint
Waiting for 21 seconds
Window Found : XYZ - Installation Wizard
FindElementByUid found : 92
[18:48:50] [Info] Click on 'type: ControlType.Button, uid: 92, name: Next >' element at (1258, 925) ClickablePoint
Waiting for 4 seconds

Due to this my further clicks are not happening and getting null reference exception.
Though the output seems it has clicked, but the click is not happening on the button and it is clicking outside the application window due to which the actual window loses focus.

I have no clue why I am getting this issue.
I am using FindElementByUid() but I have also tried FindElementByName()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.