Best Selenium code snippet using Selenium.WebDriver.Remote.htmlunit
Rakefile
Source:Rakefile
...23task :all => [:'selenium-java']24task :all_zip => [:'selenium-java_zip']25task :chrome => [:'webdriver-chrome']26task :common => [:'webdriver-common']27task :htmlunit => [:'webdriver-htmlunit']28task :ie => [:'webdriver-ie']29task :firefox => [:'webdriver-firefox']30task :jobbie => [:ie]31task :jsapi => :'webdriver-jsapi'32task :remote => [:remote_common, :remote_server, :remote_client]33task :remote_common => [:'webdriver-remote-common']34task :remote_client => [:'webdriver-remote-client']35task :remote_server => [:'webdriver-remote-server']36task :selenium => [:'webdriver-selenium']37task :support => [:'webdriver-support']38task :iphone_client => [:'webdriver-iphone-client']39task :iphone => [:iphone_server, :iphone_client]4041task :test_common => [:'webdriver-common-test']42task :test_chrome => [:'webdriver-chrome-test']43task :test_htmlunit => [:'webdriver-htmlunit-test']44task :test_ie => [:'webdriver-ie-test']45task :test_jobbie => [:test_ie]46task :test_jsapi => :'webdriver-jsapi-test'47task :test_firefox => [:'webdriver-firefox-test']48task :test_remote => [:'webdriver-selenium-server-test']49task :test_selenium => [:'webdriver-selenium-server-test', :'webdriver-selenium-test', :'webdriver-selenese-test']50task :test_support => [:'webdriver-support-test']51task :test_iphone_client => [:'webdriver-iphone-client-test']52task :test_iphone => [:test_iphone_server, :test_iphone_client]5354task :test_core => [:'test_core_firefox']55if (windows?)56 task :test_core => [:'test_core_ie']57end5859task :build => [:all, :iphone, :remote, :selenium]60task :test => [61 :test_htmlunit,62 :test_firefox,63 :test_ie,64 :test_support,65 :test_chrome,66 :test_remote,67 :test_selenium,68 :test_core69 ]7071task :clean do72 rm_rf 'build/', :verbose => false73 rm_rf 'iphone/build/', :verbose => false74end7576java_jar(:name => "webdriver-chrome",77 :srcs => [ "chrome/src/java/**/*.java" ],78 :deps => [79 :common,80 :remote_client,81 :chrome_extension,82 "remote/common/lib/runtime/*.jar"83 ],84 :resources => [ :'chrome_extension' ])8586java_test(:name => "webdriver-chrome-test",87 :srcs => [ "chrome/test/java/**/*.java" ],88 :deps => [89 :chrome,90 :'webdriver-remote-common-test'91 ])9293java_jar(:name => 'webdriver-common',94 :srcs => [ 'common/src/java/**/*.java' ])9596java_jar(:name => 'webdriver-common-test',97 :srcs => [ "common/test/java/**/*.java" ],98 :resources => [ "common/test/java/org/openqa/selenium/messages.properties" => "org/openqa/selenium/messages.properties" ],99 :deps => [100 :'webdriver-common',101 "common/lib/buildtime/*.jar"102 ])103104java_jar(:name => 'webdriver-htmlunit',105 :srcs => [ 'htmlunit/src/java/**/*.java'],106 :deps => [107 :'webdriver-common',108 'htmlunit/lib/runtime/*.jar'109 ])110111java_test(:name => 'webdriver-htmlunit-test',112 :srcs => [ "htmlunit/test/java/**/*.java" ],113 :deps => [114 :htmlunit,115 :'webdriver-common-test',116 ])117118dll(:name => "ie_win32_dll",119 :src => [ "common/src/cpp/webdriver-interactions/**/*", "jobbie/src/cpp/InternetExplorerDriver/**/*" ],120 :solution => "WebDriver.sln",121 :out => "Win32/Release/InternetExplorerDriver.dll",122 :prebuilt => "jobbie/prebuilt")123124dll(:name => "ie_x64_dll",125 :src => [ "common/src/cpp/webdriver-interactions/**/*", "jobbie/src/cpp/InternetExplorerDriver/**/*" ],126 :solution => "WebDriver.sln",127 :out => "x64/Release/InternetExplorerDriver.dll",128 :prebuilt => "jobbie/prebuilt")129130dotnet_library(:name => "build/Win32/Release/WebDriver.Common.dll",131 :srcs => [ "common/src/csharp/**/*.cs" ],132 :solution => "WebDriver.sln",133 :project => "webdriver-common",134 :arch => "Win32",135 :prebuilt => "common/prebuilt")136137dotnet_library(:name => "build/x64/Release/WebDriver.Common.dll",138 :srcs => [ "common/src/csharp/**/*.cs" ],139 :solution => "WebDriver.sln",140 :project => "webdriver-common",141 :arch => "x64",142 :prebuilt => "common/prebuilt")143144dotnet_library(:name => "build/Win32/Release/webdriver-common-test.dll",145 :srcs => [ "common/test/csharp/**/*.cs" ],146 :solution => "WebDriver.sln",147 :project => "webdriver-common-test",148 :arch => "Win32",149 :prebuilt => "common/prebuilt")150151dotnet_library(:name => "build/x64/Release/webdriver-common-test.dll",152 :srcs => [ "common/test/csharp/**/*.cs" ],153 :solution => "WebDriver.sln",154 :project => "webdriver-common-test",155 :arch => "x64",156 :prebuilt => "common/prebuilt")157158dotnet_library(:name => "build/Win32/Release/WebDriver.Ie.dll",159 :srcs => [ "jobbie/src/csharp/**/*.cs" ],160 :solution => "WebDriver.sln",161 :project => "webdriver-ie",162 :arch => "Win32",163 :prebuilt => "jobbie/prebuilt")164165dotnet_library(:name => "build/x64/Release/WebDriver.Ie.dll",166 :srcs => [ "jobbie/src/csharp/**/*.cs" ],167 :solution => "WebDriver.sln",168 :project => "webdriver-ie",169 :arch => "x64",170 :prebuilt => "jobbie/prebuilt")171172dotnet_library(:name => "build/Win32/Release/webdriver-ie-test.dll",173 :srcs => [ "jobbie/test/csharp/**/*.cs" ],174 :solution => "WebDriver.sln",175 :project => "webdriver-ie-test",176 :arch => "Win32",177 :prebuilt => "jobbie/prebuilt")178179dotnet_library(:name => "build/x64/Release/webdriver-ie-test.dll",180 :srcs => [ "jobbie/test/csharp/**/*.cs" ],181 :solution => "WebDriver.sln",182 :project => "webdriver-ie-test",183 :arch => "x64",184 :prebuilt => "jobbie/prebuilt")185dotnet_library(:name => "build/Win32/Release/WebDriver.Firefox.dll",186 :srcs => [ "firefox/src/csharp/**/*.cs" ],187 :solution => "WebDriver.sln",188 :project => "webdriver-firefox",189 :arch => "Win32",190 :prebuilt => "firefox/prebuilt")191192dotnet_library(:name => "build/x64/Release/WebDriver.Firefox.dll",193 :srcs => [ "firefox/src/csharp/**/*.cs" ],194 :solution => "WebDriver.sln",195 :project => "webdriver-firefox",196 :arch => "x64",197 :prebuilt => "firefox/prebuilt")198199dotnet_library(:name => "build/Win32/Release/webdriver-firefox-test.dll",200 :srcs => [ "firefox/test/csharp/**/*.cs" ],201 :solution => "WebDriver.sln",202 :project => "webdriver-firefox-test",203 :arch => "Win32",204 :prebuilt => "firefox/prebuilt")205206dotnet_library(:name => "build/x64/Release/webdriver-firefox-test.dll",207 :srcs => [ "firefox/test/csharp/**/*.cs" ],208 :solution => "WebDriver.sln",209 :project => "webdriver-firefox-test",210 :arch => "x64",211 :prebuilt => "firefox/prebuilt")212dotnet_library(:name => "build/Win32/Release/WebDriver.Remote.dll",213 :srcs => [ "remote/client/src/csharp/**/*.cs" ],214 :solution => "WebDriver.sln",215 :project => "webdriver-remote",216 :arch => "Win32")217218dotnet_library(:name => "build/x64/Release/WebDriver.Remote.dll",219 :srcs => [ "remote/client/src/csharp/**/*.cs" ],220 :solution => "WebDriver.sln",221 :project => "webdriver-remote",222 :arch => "x64")223224dotnet_library(:name => "build/Win32/Release/webdriver-remote-test.dll",225 :srcs => [ "remote/client/test/csharp/**/*.cs" ],226 :solution => "WebDriver.sln",227 :project => "webdriver-remote-test",228 :arch => "Win32")229230dotnet_library(:name => "build/x64/Release/webdriver-remote-test.dll",231 :srcs => [ "remote/client/test/csharp/**/*.cs" ],232 :solution => "WebDriver.sln",233 :project => "webdriver-remote-test",234 :arch => "x64")235236task :dotnet => [ :'build/x64/Release/webdriver-ie-test.dll', :'build/Win32/Release/webdriver-ie-test.dll',237 :'build/x64/Release/Webdriver.Ie.dll', :'build/Win32/Release/Webdriver.Ie.dll',238 :'build/x64/Release/webdriver-firefox-test.dll', :'build/Win32/Release/webdriver-firefox-test.dll',239 :'build/x64/Release/Webdriver.Firefox.dll', :'build/Win32/Release/Webdriver.Firefox.dll',240 :'build/x64/Release/webdriver-remote-test.dll', :'build/Win32/Release/webdriver-remote-test.dll',241 :'build/x64/Release/Webdriver.Remote.dll', :'build/Win32/Release/Webdriver.Remote.dll',242 :'build/x64/Release/webdriver-common-test.dll', :'build/Win32/Release/webdriver-common-test.dll',243 :'build/x64/Release/Webdriver.Common.dll', :'build/Win32/Release/Webdriver.Common.dll',244 :ie_win32_dll, :ie_x64_dll ]245246# Generate a C++ Header file for mapping between magic numbers and #defines247# in the C++ code.248ie_generate_type_mapping(:name => "ie_result_type_cpp",249 :src => "jobbie/src/common/result_types.txt",250 :type => "cpp",251 :out => "cpp/InternetExplorerDriver/IEReturnTypes.h")252253# Generate a Java class for mapping between magic numbers and Java static254# class members describing them.255ie_generate_type_mapping(:name => "ie_result_type_java",256 :src => "jobbie/src/common/result_types.txt",257 :type => "java",258 :out => "java/org/openqa/selenium/ie/IeReturnTypes.java")259260java_jar(:name => "webdriver-ie",261 :srcs => [ "jobbie/src/java/**/*.java" ],262 :deps => [263 :'webdriver-common',264 "jobbie/lib/runtime/*.jar",265 :ie_result_type_java,266 :ie_result_type_cpp267 ],268 :resources => [269 {:ie_win32_dll => "x86/InternetExplorerDriver.dll"},270 {:ie_x64_dll => "amd64/InternetExplorerDriver.dll"},271 ])272273java_test(:name => "webdriver-ie-test",274 :srcs => [ "jobbie/test/java/**/*.java" ],275 :deps => [276 :ie,277 :test_common278 ],279 :run => windows?)280281xpt(:name => "events_xpt",282 :src => [ "firefox/src/cpp/webdriver-firefox/nsINativeEvents.idl" ],283 :prebuilt => "firefox/prebuilt",284 :out => "nsINativeEvents.xpt")285286xpt(:name => "responseHandler_xpt",287 :src => [ "firefox/src/extension/idl/nsIResponseHandler.idl" ],288 :prebuilt => "firefox/prebuilt",289 :out => "nsIResponseHandler.xpt")290291xpt(:name => "commandProcessor_xpt",292 :src => [ "firefox/src/extension/idl/nsICommandProcessor.idl" ],293 :deps => [ :responseHandler_xpt ],294 :prebuilt => "firefox/prebuilt",295 :out => "nsICommandProcessor.xpt")296297xpi(:name => "firefox_xpi",298 :srcs => [ "firefox/src/extension/**" ],299 :deps => [300 :firefox_dll,301 :libwebdriver_firefox,302 ],303 :resources => [304 { "firefox/src/extension/components/*.js" => "components/" },305 { "common/src/js/extension/*.js" => "content/" },306 { :commandProcessor_xpt => "components/" },307 { :events_xpt => "components/" },308 { :responseHandler_xpt => "components/" },309 { :firefox_dll => "platform/WINNT_x86-msvc/components/webdriver-firefox.dll" },310 { :libwebdriver_firefox_so => "platform/Linux_x86-gcc3/components/libwebdriver-firefox.so" },311 { :libwebdriver_firefox_so64 => "platform/Linux_x86_64-gcc3/components/libwebdriver-firefox.so" },312 ],313 :out => "webdriver-extension.zip")314315dll(:name => "firefox_dll",316 :src => [ "common/src/cpp/webdriver-interactions/**/*", "jobbie/src/cpp/webdriver-firefox/**/*" ],317 :solution => "WebDriver.sln",318 :out => "Win32/Release/webdriver-firefox.dll",319 :deps => [ 320 :events_xpt,321 ],322 :prebuilt => "firefox/prebuilt")323324dll(:name => "libnoblur_so_64",325 :src => FileList['firefox/src/cpp/linux-specific/*.c'],326 :arch => "amd64",327 :prebuilt => "firefox/prebuilt",328 :out => "linux64/Release/x_ignore_nofocus.so")329330dll(:name => "libnoblur_so",331 :src => FileList['firefox/src/cpp/linux-specific/*.c'],332 :arch => "i386",333 :prebuilt => "firefox/prebuilt",334 :out => "linux/Release/x_ignore_nofocus.so")335336task :libnoblur => [:libnoblur_so, :libnoblur_so_64]337338gecko_sdk = "third_party/gecko-1.9.0.11/linux/"339340dll(:name => "libwebdriver_firefox_so",341 :src => FileList.new('common/src/cpp/webdriver-interactions/*_linux.cpp') +342 FileList.new('firefox/src/cpp/webdriver-firefox/*.cpp'),343 :arch => "i386",344 :args => " -DXPCOM_GLUE -DXPCOM_GLUE_USE_NSPR -I common/src/cpp/webdriver-interactions -I #{gecko_sdk}include -I /usr/include/nspr " + "`pkg-config gtk+-2.0 --cflags`",345 :link_args => "-fno-rtti -fno-exceptions -shared -fPIC -L#{gecko_sdk}lib -L#{gecko_sdk}bin -Wl,-rpath-link,#{gecko_sdk}bin -lxpcomglue_s -lxpcom -lnspr4 -lrt ",346 :prebuilt => "firefox/prebuilt",347 :out => "linux/Release/libwebdriver-firefox.so")348349# There is no official 64 bit gecko SDK. Fall back to trying to use the one on 350# system, but be ready for this to fail. I have a Ubuntu machine, so that's 351# what I'm basing this on. I understand that's a Bad Idea352353gecko_devels = FileList.new("/usr/lib/xulrunner-devel-1.9.*/sdk")354local_gecko = gecko_devels.empty? ? "" : gecko_devels.to_a[0] + "/" 355356dll(:name => "libwebdriver_firefox_so64",357 :src => FileList.new('common/src/cpp/webdriver-interactions/*_linux.cpp') + FileList.new('firefox/src/cpp/webdriver-firefox/native_events.cpp'),358 :arch => "amd64",359 :args => " -DXPCOM_GLUE -DXPCOM_GLUE_USE_NSPR -fPIC -fshort-wchar -I common/src/cpp/webdriver-interactions -I #{local_gecko}include -I /usr/include/nspr `pkg-config gtk+-2.0 --cflags` ",360 :link_args => "-Wall -Os -L#{local_gecko}lib -L#{local_gecko}bin -Wl,-rpath-link,#{local_gecko}bin -lxpcomglue_s -lxpcom -lnspr4 -lrt `pkg-config gtk+-2.0 --libs` -fno-rtti -fno-exceptions -shared -fPIC",361 :prebuilt => "firefox/prebuilt",362 :out => "linux64/Release/libwebdriver-firefox.so")363364task :libwebdriver_firefox => [:libwebdriver_firefox_so, :libwebdriver_firefox_so64]365366java_jar(:name => "webdriver-firefox",367 :srcs => [ "firefox/src/java/**/*.java" ],368 :deps => [369 :common,370 :firefox_xpi,371 :libnoblur,372 "firefox/lib/runtime/*.jar"373 ],374 :resources => [ 375 :firefox_xpi,376 { "linux/Release/x_ignore_nofocus.so" => "x86/x_ignore_nofocus.so" },377 { "linux64/Release/x_ignore_nofocus.so" => "amd64/x_ignore_nofocus.so" }378 ])379380java_test(:name => "webdriver-firefox-test",381 :srcs => [ "firefox/test/java/**/*.java" ],382 :deps => [383 :'webdriver-firefox',384 :'webdriver-common-test',385 ])386387java_test(:name => "ide-test",388 :srcs => [ "ide/test/java/**/*.java" ],389 :deps => [390 :'webdriver-firefox',391 :'webdriver-common-test',392 "se_ide:ensure_proxy_setup"393 ])394 395java_test(:name => "webdriver-single-testsuite",396 :srcs => [ "common/test/java/org/openqa/selenium/SingleTestSuite.java"],397 :deps => [398 :'webdriver-ie',399 :'webdriver-common-test',400 ])401402java_jar(:name => "webdriver-support",403 :srcs => [ "support/src/java/**/*.java" ],404 :deps => [405 :common,406 "support/lib/runtime/*.jar",407 "third_party/java/google-collect-1.0.jar",408 ])409410java_test(:name => "webdriver-support-test",411 :srcs => [ "support/test/java/**/*.java" ],412 :deps => [413 :support,414 :test_common,415 ])416417java_jar(:name => "webdriver-remote-common",418 :srcs => [ "remote/common/src/java/**/*.java" ],419 :deps => [420 :common,421 "remote/common/lib/runtime/*.jar",422 "third_party/java/google-collect-1.0.jar",423 ])424425java_jar(:name => "webdriver-remote-client",426 :srcs => [ "remote/client/src/java/**/*.java" ],427 :deps => [428 :common,429 :'webdriver-remote-common',430 "remote/client/lib/runtime/*.jar",431 ])432433xpt(:name => "ide-auto-complete",434 :src => [ "ide/src/extension/idl/SeleniumIDEGenericAutoCompleteSearch.idl" ],435 :prebuilt => "ide/prebuilt",436 :out => "SeleniumIDEGenericAutoCompleteSearch.xpt")437438xpi(:name => "ide",439 :srcs => [],440 :deps => [],441 :resources => [442 { "ide/src/extension/chrome/" => "/" },443 { "common/src/js/core/*" => "chrome/content/selenium/"},444 { "ide/src/extension/content" => "chrome/" },445 { "ide/src/extension/skin" => "chrome/" },446 { "ide/src/extension/locale" => "chrome/" },447 { :"ide-auto-complete" => "components/" },448 { "ide/src/extension/components/SeleniumIDEGenericAutoCompleteSearch.js" => "components/" },449 { "ide/src/extension/install.rdf" => "/" },450 { "ide/src/extension/chrome.manifest.production" => "/chrome.manifest" },451 { "common/src/js/core/scripts/selenium-testrunner.js" => "content-files/" }452 ],453 :out => "selenium-ide-1.0.6-SNAPSHOT.xpi")454455java_jar(:name => "selenium-common-js",456 :resources => [457 "common/src/js/core",458 "common/src/js/jsunit",459 {460 "common/src/js/core/TestRunner.html" => "core/TestRunner.hta",461 "common/src/js/core/RemoteRunner.html" => "core/RemoteRunner.hta",462 }])463464java_jar(:name => "webdriver-remote-server",465 :srcs => [ "remote/server/src/java/**/*.java" ],466 :resources => [467 {468 "remote/server/src/java/org/openqa/jetty/http/mime.properties" => "org/openqa/jetty/http/mime.properties",469 "remote/server/src/java/org/openqa/jetty/http/encoding.properties" => "org/openqa/jetty/http/encoding.properties",470 },471 "remote/server/src/java/customProfileDir*",472 "remote/server/src/java/cybervillains",473 "remote/server/src/java/hudsuckr",474 "remote/server/src/java/killableprocess",475 "remote/server/src/java/konqueror",476 "remote/server/src/java/opera",477 "remote/server/src/java/sslSupport",478 "remote/server/src/java/VERSION.txt",479 "common/src/js/core",480 "common/src/js/jsunit",481 {482 "common/src/js/core/TestRunner.html" => "core/TestRunner.hta",483 "common/src/js/core/RemoteRunner.html" => "core/RemoteRunner.hta",484 },485 ],486 :deps => [487 :chrome,488 :htmlunit,489 :ie,490 :firefox,491 :remote_common,492 :selenium,493 :support,494 "remote/server/lib/runtime/*.jar"495 ])496497java_uberjar(:name => "selenium-server",498 :deps => [ "webdriver-remote-server", :selenium ],499 :exclude => [500 "META-INF/BCKEY.*"501 ],502 :main => "org.openqa.selenium.server.SeleniumServer",503 :no_libs => true)504 505task :'selenium-server_zip' do506 temp = "build/selenium-server_zip"507 mkdir_p temp508 sh "cd #{temp} && jar xf ../selenium-server.zip", :verbose => false509 rm_f "build/selenium-server.zip"510 Dir["#{temp}/webdriver-*.jar"].each { |file| rm_rf file }511 mv "#{temp}/selenium-server.jar", "#{temp}/selenium-server-#{version}.jar"512 sh "cd #{temp} && jar cMf ../selenium-server.zip *", :verbose => false513end514515java_uberjar(:name => "selenium-server-standalone",516 :deps => [ :'selenium-server' ],517 :standalone => true,518 :exclude => [519 "META-INF/BCKEY.*"520 ],521 :main => "org.openqa.selenium.server.SeleniumServer")522523java_jar(:name => "webdriver-remote-common-test",524 :srcs => [ "remote/common/test/java/**/*.java" ],525 :deps => [526 :remote_common,527 :test_common528 ])529530java_test(:name => "webdriver-selenium-server-test",531 :srcs => [532 "remote/client/test/java/**/*.java",533 "remote/server/test/java/org/openqa/selenium/remote/**/*.java",534 "remote/server/test/java/org/openqa/selenium/server/**/*.java",535 "remote/server/test/java/org/openqa/selenium/testworker/**/*.java"536 ],537 :deps => [538 :remote_client,539 :remote_server,540 :test_common,541 :'webdriver-remote-common-test',542 "remote/server/lib/buildtime/*.jar"543 ])544545java_war(:name => "webdriver-remote-servlet",546 :deps => [ :'webdriver-remote-server' ],547 :resources => [548 "remote/server/src/web/**"549 ]550 )551552dll(:name => "chrome_dll",553 :src => [ "common/src/cpp/webdriver-interactions/**/*", "chome/src/cpp/**/*" ],554 :solution => "WebDriver.sln",555 :out => 'Win32/Release/npchromedriver.dll',556 :prebuilt => "chrome/prebuilt")557558xpi(:name => "chrome_extension",559 :srcs => [ "chrome/src/extension/**" ],560 :deps => [ :chrome_dll ],561 :resources => [562 { :chrome_dll => "npchromedriver.dll" }563 ],564 :out => "chrome-extension.zip")565566java_jar(:name => "webdriver-selenium",567 :srcs => [ "selenium/src/java/**/*.java" ],568 :deps => [569 :chrome,570 :ie,571 :firefox,572 :remote_client,573 :support,574 "selenium/lib/runtime/*.jar"575 ],576 :resources => [577 { "selenium/src/java/org/openqa/selenium/internal/seleniumemulation/injectableSelenium.js" => "org/openqa/selenium/internal/seleniumemulation/injectableSelenium.js" },578 { "selenium/src/java/org/openqa/selenium/internal/seleniumemulation/htmlutils.js" => "org/openqa/selenium/internal/seleniumemulation/htmlutils.js" }579 ])580581java_test(:name => "webdriver-selenium-test",582 :srcs => [ "selenium/test/java/**/*.java" ],583 :resources => [584 { "selenium/test/java/com/thoughtworks/selenium/testHelpers.js" => "com/thoughtworks/selenium/testHelpers.js" },585 ],586 :deps => [587 :test_common,588 :htmlunit,589 :'selenium-server-standalone',590 "selenium/lib/buildtime/*.jar",591 ],592 :main => "org.testng.TestNG",593 :args => "selenium/test/java/webdriver-selenium-suite.xml")594595java_test(:name => "webdriver-selenese-test",596 :srcs => [ "selenium/test/java/**/*.java" ],597 :deps => [598 :test_common,599 :htmlunit,600 :'selenium-server-standalone',601 "selenium/lib/buildtime/*.jar",602 ])603604java_jar(:name => "selenium-core",605 :resources => [606 {"selenium/test/js/**" => "tests"},607 "common/src/js/core"608 ])609610selenium_test(:name => "test_core_firefox",611 :srcs => [ "common/test/js/core/*.js" ],612 :deps => [ 613 :"webdriver-remote-server",614 :"selenium-core" 615 ],616 :browser => "*chrome" )617 618selenium_test(:name => "test_core_ie",619 :srcs => [ "common/test/js/core/*.js" ],620 :deps => [ 621 :"webdriver-remote-server",622 :"selenium-core" 623 ],624 :browser => "*iexploreproxy")625626java_jar(:name => "webdriver-jsapi",627 :srcs => [ "remote/server/test/java/**/JsApi*.java" ],628 :deps => [ :firefox, :test_common ])629630# Comprehensive test suite for testing the JS API in isolation against all of631# the supported browsers. This should be included in the :test task; for that we632# defer to the suites for the individual drivers.633java_test(:name => "webdriver-jsapi-test",634 :srcs => [ "jsapi/test/java/**/*.java" ],635 :deps => [ :firefox, :chrome, :test_common ])636637# Simply starts the Jetty6AppServer for manually testing the JS API tests.638# After starting, open a browser to http://localhost:$PORT/js/test, where $PORT639# is the port the server was started on.640java_test(:name => "debug_jsapi",641 :deps => [ :firefox, :test_common ],642 :main => "org.openqa.selenium.environment.webserver.Jetty6AppServer")643644task :javadocs => [:common, :firefox, :htmlunit, :jobbie, :remote, :support, :chrome, :selenium] do645 mkdir_p "build/javadoc", :verbose => false646 sourcepath = ""647 classpath = "support/lib/runtime/hamcrest-all-1.1.jar"648 %w(common firefox jobbie htmlunit support remote/common remote/client chrome selenium).each do |m|649 sourcepath += ":#{m}/src/java"650 end651 cmd = "javadoc -d build/javadoc -sourcepath #{sourcepath} -classpath #{classpath} -subpackages org.openqa.selenium -subpackages com.thoughtworks"652 if (windows?) 653 cmd = cmd.gsub(/\//, "\\").gsub(/:/, ";") 654 end655 sh cmd656end657658task :test_firefox_py => [:firefox, :firefox_xpi] do659 if python? then660 sh "virtualenv build/python", :verbose => true do |ok, res|661 if ! ok662 puts ""663 puts "PYTHON DEPENDENCY ERROR: Virtualenv not found."664 puts "Please run '[sudo] pip install virtualenv'"665 puts ""666 end667 end668 sh "build/python/bin/pip install simplejson py", :verbose => true669 cp 'build/webdriver-extension.zip', "firefox/src/py/", :verbose => true670 sh "build/python/bin/python setup.py build", :verbose => true671 if File.exists?('build/python/bin/py.test')672 py_test = 'build/python/bin/py.test'673 else674 py_test = 'py.test'675 end676 test_dir = Dir.glob('build/lib**/selenium/firefox_tests').first677 sh py_test, test_dir, :verbose => true678 end679end680681task :test_selenium_py => [:'selenium-core', :'selenium-server-standalone'] do682 if python? then683 sh "python2.6 selenium/test/py/runtests.py", :verbose => true684 end685end686687# Place-holder tasks688java_jar(:name => "webdriver-iphone-client",689 :srcs => [ "iphone/src/java/**/*.java" ],690 :deps => [691 :common,692 :remote_common,693 :remote_client694 ])695696iphone_test(:name => "webdriver-iphone-client-test",697 :srcs => [ "iphone/test/java/**/*.java" ],698 :deps => [699 :test_common,700 :iphone_server,701 :iphone_client702 ])703704705#### iPhone ####706task :iphone_server do707 sdk = iPhoneSDK?708 if sdk != nil then709 puts "Building iWebDriver iphone app"710 sh "cd iphone && xcodebuild -sdk #{sdk} ARCHS=i386 -target iWebDriver >/dev/null", :verbose => false711 else712 puts "XCode not found. Not building the iphone driver."713 end714end715716# This does not depend on :iphone_server because the dependancy is specified in xcode717task :test_iphone_server do718 sdk = iPhoneSDK?719 if sdk != nil then720 sh "cd iphone && xcodebuild -sdk #{sdk} ARCHS=i386 -target Tests"721 else722 puts "XCode and/or iPhoneSDK not found. Not testing iphone_server."723 end724end725726def version727 `svn info | grep Revision | awk -F: '{print $2}' | tr -d '[:space:]' | tr -d '\n'`728end729730task :remote_release => [:remote] do731 mkdir_p "build/dist/remote_client", :verbose => false732733 cp 'remote/build/webdriver-remote-client.jar', 'build/dist/remote_client'734 cp 'remote/build/webdriver-remote-common.jar', 'build/dist/remote_client'735 cp 'common/build/webdriver-common.jar', 'build/dist/remote_client'736737 cp Dir.glob('remote/common/lib/runtime/*.jar'), 'build/dist/remote_client'738 cp Dir.glob('remote/client/lib/runtime/*.jar'), 'build/dist/remote_client'739 cp 'third_party/java/google-collect-1.0.jar', 'build/dist/remote_client'740741 sh "cd build/dist && zip -r webdriver-remote-client-#{version}.zip remote_client/*"742 rm_rf "build/dist/remote_client", :verbose => false743744 mkdir_p "build/dist/remote_server", :verbose => false745746 cp 'remote/build/webdriver-remote-server.jar', 'build/dist/remote_server'747 cp 'remote/build/webdriver-remote-common.jar', 'build/dist/remote_server'748 cp 'common/build/webdriver-common.jar', 'build/dist/remote_server'749750 cp Dir.glob('remote/common/lib/runtime/*.jar'), 'build/dist/remote_server'751 cp Dir.glob('remote/server/lib/runtime/*.jar'), 'build/dist/remote_server'752 cp 'third_party/java/google-collect-1.0.jar', 'build/dist/remote_server'753754 rm Dir.glob('build/dist/remote_server/servlet*.jar')755756 sh "cd build/dist && zip -r webdriver-remote-server-#{version}.zip remote_server/*"757 rm_rf "build/dist/remote_server", :verbose => false758end759760java_uberjar(:name => "selenium-java",761 :deps => [762 :chrome,763 :htmlunit,764 :ie,765 :firefox,766 :remote_client,767 :selenium,768 :support769 ],770 :no_libs => true)771772task :release => [:'all_zip', :'selenium-server-standalone', :'selenium-server_zip'] do773 cp "build/selenium-server-standalone.jar", "build/selenium-server-standalone-#{version}.jar"774 cp "build/selenium-java.zip", "build/selenium-java-#{version}.zip"775 cp "build/selenium-server.zip", "build/selenium-server-#{version}.zip"776end777
...
provider.rb
Source:provider.rb
...4849 def new_browser(browser_type='firefox')50 case @browser.inspect51 when "Selenium::WebDriver"52 if browser_type == :htmlunit53 caps = Selenium::WebDriver::Remote::Capabilities.htmlunit(:javascript_enabled => true)54 @browser.for(:remote, :url => "http://127.0.0.1:4444/wd/hub", :desired_capabilities => caps)55 else56 @browser.for browser_type.to_sym57 end58 when "Watir::Browser"59 if @browser_type == :htmlunit60 caps = Selenium::WebDriver::Remote::Capabilities.htmlunit(:javascript_enabled => true)61 @browser.new(:remote, :url => "http://127.0.0.1:4444/wd/hub", :desired_capabilities => caps)62 else63 @browser.new browser_type.to_sym64 end65 when "Watir::Safari"66 @browser.new67 when "FireWatir::Firefox"68 @browser.new69 when "Watir::IE"70 @browser.new71 else72 @browser.new73 end74 end
...
WebDriverFactory.rb
Source:WebDriverFactory.rb
...57 # Phantomjs.run('./path/to/script.js') # => returns stdout58 # driver = Selenium::WebDriver.for(:remote, :url => "http://localhost:9134")59 elsif browser_type == 'HTMLUNIT'60 p 'run HtmlUnit'61 driver = Selenium::WebDriver.for :remote, :url => "http://localhost:4444/wd/hub", :desired_capabilities => :htmlunit62 else63 p 'run firefox'64 # require "selenium-webdriver"65 driver = Selenium::WebDriver.for :firefox66 end67 return driver68 end69# driver = web_driver_factory()70# driver.navigate.to "https://jlv.vistacore.us/jlv/"71end...
htmlunit
Using AI Code Generation
1element = driver.find_element(:name, 'q')2element = driver.find_element(:name, 'q')3element = driver.find_element(:name, 'q')4element = driver.find_element(:name, 'q')5element = driver.find_element(:name, 'q')
htmlunit
Using AI Code Generation
1driver = Selenium::WebDriver.for(:remote, :url => 'http://localhost:4444/wd/hub', :desired_capabilities => :firefox)2driver.get('http://www.google.com')3driver = Selenium::WebDriver.for(:remote, :url => 'http://localhost:4444/wd/hub', :desired_capabilities => :firefox)4driver.get('http://www.google.com')5driver = Selenium::WebDriver.for(:remote, :url => 'http://localhost:4444/wd/hub', :desired_capabilities => :firefox)6driver.get('http://www.google.com')7driver = Selenium::WebDriver.for(:remote, :url => 'http://localhost:4444/wd/hub', :desired_capabilities => :firefox)8driver.get('http://www.google.com')9driver = Selenium::WebDriver.for(:remote, :url => 'http://localhost:4444/wd/hub', :desired_capabilities => :firefox)10driver.get('http://www.google.com')
htmlunit
Using AI Code Generation
1File.open("1.html", "w") do |f|2 f.write(driver.page_source)3File.open("2.html", "w") do |f|4 f.write(driver.page_source)5File.open("3.html", "w") do |f|6 f.write(driver.page_source)
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!