Skip to content

Instantly share code, notes, and snippets.

syntax = scope;
enum STPType
{
COMMAND = 1;
RESPONSE = 2;
EVENT = 3;
ERROR = 4;
}
// Assume driver is a WebDriver instance,
// and element is a WebElement instance.
Actions actionsProvider = new Actions(driver);
actionsProvider.moveToElement(element).perform();
require 'rubygems'
require 'selenium-webdriver'
profile = Selenium::WebDriver::Firefox::Profile.new
caps = Selenium::WebDriver::Remote::Capabilities.firefox
caps.firefox_profile = profile
caps = Selenium::WebDriver.for :remote, :url => "http://localhost:4444/wd/hub", :desired_capabilities => caps
bool HtmlDialog::Wait() {
// If the window handle is no longer valid, the window is closing,
// the wait is completed, and we must post the quit message.
if (!::IsWindow(this->GetTopLevelWindowHandle())) {
this->is_navigating_ = false;
this->set_is_closing(true);
this->PostQuitMessage();
return true;
}
require 'rubygems'
require 'selenium-webdriver'
def wait_for_new_handle(original_handles, driver)
handles = nil
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
wait.until do
handles = driver.window_handles
handles.size == original_handles.size + 1
end
// Assume driver is a valid IWebDriver instance.
IWebElement buttonsetElement = driver.FindElement(By.ClassName("ui-dialog-buttonset");
IList<IWebElement> buttons = buttonsetElement.FindElements(By.TagName("button"));
buttons[0].Click();
<html>
<head>
<title>Modal dialog launcher</title>
</head>
<body>
<p>This launches the test page using showModalDialog:
<a href="#"
id="dialog"
onclick="showModalDialog('click_test.html', null, 'dialogHeight:768px;dialogWidth:1024px;resizable:yes')">
launch test
//Wait until "Processing" objects goes away
DateTime endTime = DateTime.Now.Add(TimeSpan.FromSeconds(10));
while (driver.FindElement(By.CssSelector("div[id*='processing']")).Displayed && DateTime.Now < endTime)
{
Thread.Sleep(100);
}
window.document.__webdriver_script_fn = (function() { return function(){var e = arguments[0];
var p = e.parentNode;
var x = e.offsetLeft + (e.clientWidth / 2);
var y = e.offsetTop + (e.clientHeight / 2);
var s = window.getComputedStyle ? window.getComputedStyle(p, null) : p.currentStyle;
// Condition changed. It was: while (p != null && s.overflow != 'auto' &&
// s.overflow != 'scroll' && s.overflow != 'hidden')
while (p != null &&
s != null &&
s.overflow &&
/**
* Determine the outer size of the window.
*
* @param {!Window=} opt_win Window to determine the size of. Defaults to
* bot.getWindow().
* @return {!goog.math.Size} The calculated size.
*/
bot.window.getSize = function(opt_win) {
var win = opt_win || bot.getWindow();