based on UIAutomationRef.pdf
エレメントは階層構造になっている UIATarget.localTarget()を最上位とする
| -- Sublime Text 2をアクティブにする | |
| tell application "Sublime Text 2" | |
| activate | |
| end tell | |
| -- Sublime Text 2の現在行を選択して、切り出す | |
| tell application "System Events" | |
| -- ことえり単語登録(== "WordRegister") | |
| tell application "WordRegister" | |
| activate | |
| end tell | |
| tell application "System Events" | |
| -- 単語の欄にペースト |
| // Selenium RCの場合 | |
| selenium.chooseCancelOnNextConfirmation(); | |
| selenium.click("id=foo"); | |
| // WebDriverの場合 | |
| webdriver.findElement(By.id("foo")).click(); | |
| webdriver.switchTo().alert().dismiss(); |
| // Selenium RCの場合 => openの後waitが必要 | |
| selenium.open("http://www.google.com"); | |
| selenium.waitForPageToLoad(); | |
| selenium.typeKeys("name=q", "bears"); | |
| // WebDriverの場合 => openの中で暗黙的にwaitしているので、わざわざ記述は要らない | |
| selenium.open("http://www.google.com"); | |
| selenium.typeKeys("name=q", "bears"); |
| // 良くない例:<body>の中のテキストを全て取得して検証している | |
| String text = selenium.getBodyText(); | |
| assertTrue(text.contains("hello")); | |
| WebElement body = webdriver.findElement( | |
| By.tagName("body")); | |
| String text = body.getText(); | |
| assertTrue(text.contains("hello")); |
| selenium.getEval( | |
| "selenium.isElementPresent('id=foo') && " + | |
| "selenium.isVisible('id=foo')"); |
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
based on UIAutomationRef.pdf
エレメントは階層構造になっている UIATarget.localTarget()を最上位とする
| #!/bin/bash | |
| # [usage] | |
| # instruments [-t template] [-D document] [-l timeLimit] [-i #] [-w device] [[-p pid] | [application [-e variable value] [argument ...]]] | |
| # --- 環境設定 | |
| APP_NAME=<TargetAppName> | |
| # for 7.0.3-64 | |
| #SIMULATOR_VERSION=7.0.3-64 | |
| #GUID=9BAC4C3E-BBC2-4805-A115-A310CB21A941 |
| global.expect = require('chai').expect; | |
| global.sinon = require('sinon').expect; | |
| // clear console | |
| process.stdout.write('\u001b[2J\u001b[0;0H'); |