Back to Catalog
24.07.2015

Magic Samples

This article is a stub. Please help us improve it.

  • Run GBUI.Driver.exe --verbose

Python

  • Write yours calculator.py
# coding: utf-8
from selenium import webdriver

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

window = driver.find_element_by_class_name('CalcFrame')
view_menu_item = window.find_element_by_id('MenuBar').find_element_by_name('View')

view_menu_item.click()
view_menu_item.find_element_by_name('Scientific').click()

view_menu_item.click()
view_menu_item.find_element_by_name('History').click()

window.find_element_by_id('132').click()
window.find_element_by_id('93').click()
window.find_element_by_id('134').click()
window.find_element_by_id('97').click()
window.find_element_by_id('138').click()
window.find_element_by_id('121').click()

driver.close()
  • Run python calculator.py

C#

namespace ConsoleApplication
{
    using System;
    using OpenQA.Selenium;
    using OpenQA.Selenium.Remote;

    public class Program
    {
        private static void Main(string[] args)
        {
            var dc = new DesiredCapabilities();
            dc.SetCapability("app", @"C:/windows/system32/calc.exe");
            var driver = new RemoteWebDriver(new Uri("http://localhost:9999"), dc);

            var window = driver.FindElementByClassName("CalcFrame");
            var viewMenuItem = window.FindElement(By.Id("MenuBar")).FindElement(By.Name("View"));

            viewMenuItem.Click();
            viewMenuItem.FindElement(By.Name("Scientific")).Click();

            viewMenuItem.Click();
            viewMenuItem.FindElement(By.Name("History")).Click();

            window.FindElement(By.Id("132")).Click(); // 2
            window.FindElement(By.Id("93")).Click(); // +
            window.FindElement(By.Id("134")).Click(); // 4
            window.FindElement(By.Id("97")).Click(); // ^
            window.FindElement(By.Id("138")).Click(); // 8
            window.FindElement(By.Id("121")).Click(); // =

            driver.Close();
        }
    }
}

Python. The code that writes the code

namespace ConsoleApplication
{
    using System;
    using OpenQA.Selenium;
    using OpenQA.Selenium.Remote;

    public class Program
    {
        private static void Main(string[] args)
        {
            var dc = new DesiredCapabilities();
            dc.SetCapability("app", @"C:/windows/system32/calc.exe");
            var driver = new RemoteWebDriver(new Uri("http://localhost:9999"), dc);

            var window = driver.FindElementByClassName("CalcFrame");
            var viewMenuItem = window.FindElement(By.Id("MenuBar")).FindElement(By.Name("View"));

            viewMenuItem.Click();
            viewMenuItem.FindElement(By.Name("Scientific")).Click();

            viewMenuItem.Click();
            viewMenuItem.FindElement(By.Name("History")).Click();

            window.FindElement(By.Id("132")).Click(); // 2
            window.FindElement(By.Id("93")).Click(); // +
            window.FindElement(By.Id("134")).Click(); // 4
            window.FindElement(By.Id("97")).Click(); // ^
            window.FindElement(By.Id("138")).Click(); // 8
            window.FindElement(By.Id("121")).Click(); // =

            driver.Close();
        }
    }
}