Skip to content

Instantly share code, notes, and snippets.

@tk3
Created February 4, 2015 15:54
Show Gist options
  • Save tk3/0f2a6d9979902cbf67f6 to your computer and use it in GitHub Desktop.
Save tk3/0f2a6d9979902cbf67f6 to your computer and use it in GitHub Desktop.
Selenium F# memo
#light
open System
open OpenQA.Selenium
open OpenQA.Selenium.Remote
// DesiredCapabilities.InternetExplorer
// let capability = DesiredCapabilities.Chrome()
[<EntryPoint>]
let main args =
let capability = DesiredCapabilities.Firefox()
let driver = new RemoteWebDriver(capability)
driver.Navigate().GoToUrl("http://www.google.co.jp/")
driver.Quit()
printfn "Hello, world"
0
@echo off
set PATH=C:\Users\foo\devel\fsharp\samples\webdriver\selenium-dotnet-2.44.0\net40;%PATH%
open_google.exe
fsc --platform:x86 --lib:"selenium-dotnet-2.44.0\net40" -r "WebDriver.dll" open_google.fs
Tags - Yi Zeng http://yizeng.me/tags/#selenium-webdriver
selenium.getEval("window.resizeTo(X, Y); window.moveTo(0,0);")
// 画面サイズを変更する
let s = new System.Drawing.Size(1024, 768);;
driver.Manage().Window.Size <- s;;
// 現代の画面のサイズ
driver.Manage().Window.Size # Drawing.Size
driver.Manage().Window.Size.Width;;
driver.Manage().Window.Size.Height;;
// 画面最大化
driver.Manage().Window.Maximize();;
driver.Title
driver.Url
driver.Manage().Cookies
#I @"selenium-dotnet-2.44.0\net40";;
#r "WebDriver.dll";;
WebDriver.dll
chromedriver.storage.googleapis.com/index.html http://chromedriver.storage.googleapis.com/index.html
warning FS0082:
-> fsc --platform:x86 ...
Exception: unknown error: unable to discover open pages
-> chromedriver のバージョンと Chrome のバージョンの組み合わせが合っていない
WebDriverWait wait = new WebDriverWait(driver, new TimeSpan(0,0,5));
wait.Until(By.Id("login"));
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
java -jar "C:\Users\foo\devel\fsharp\samples\webdriver\selenium-server-standalone-2.44.0.jar" -Dwebdriver.ie.driver="C:\Users\foo\devel\fsharp\samples\webdriver\chromedriver.exe"
java -jar selenium-server-standalone-2.42.2.jar -Dwebdriver.ie.driver=.\IEDriverServer.exe
.
> Install the free Visual F# Tools 3.1.2 from Microsoft
Use F# on Windows | The F# Software Foundation http://fsharp.org/use/windows/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment