diff --git a/html/miniwob/click-dialog-2.html b/html/miniwob/click-dialog-2.html index 2dd3af0e..e5dfe32e 100644 --- a/html/miniwob/click-dialog-2.html +++ b/html/miniwob/click-dialog-2.html @@ -41,11 +41,11 @@ position: {my: 'center', at: 'center', of: document.getElementById('area')}, buttons: [ { text: 'Cancel', click: function(e) { - var r = e.toElement.innerHTML === expectedButton ? 1.0 : -1.0; + var r = e.target.innerHTML === expectedButton ? 1.0 : -1.0; core.endEpisode(r, r > 0); } }, { text: 'OK', click: function(e) { - var r = e.toElement.innerHTML === expectedButton ? 1.0 : -1.0; + var r = e.target.innerHTML === expectedButton ? 1.0 : -1.0; core.endEpisode(r, r > 0); } } ] diff --git a/python/README.md b/python/README.md index 8eaf056f..77140602 100644 --- a/python/README.md +++ b/python/README.md @@ -10,7 +10,7 @@ - Selenium - Outside this repository, download - [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/downloads). + [ChromeDriver](https://chromedriver.chromium.org/downloads). Unzip it and then add the directory containing the `chromedriver` executable to the `PATH` environment variable ``` diff --git a/python/miniwob/action.py b/python/miniwob/action.py index 1cc131af..22eaae63 100644 --- a/python/miniwob/action.py +++ b/python/miniwob/action.py @@ -3,11 +3,11 @@ import logging from selenium.webdriver.common.action_chains import ActionChains +from selenium.webdriver.common.by import By -class MiniWoBAction(object): +class MiniWoBAction(metaclass=abc.ABCMeta): """Defines an action in its __call__ method.""" - __metaclass__ = abc.ABCMeta @abc.abstractmethod def __call__(self, driver): @@ -61,10 +61,12 @@ def __init__(self, left, top): def __call__(self, driver): """Clicks at coordinates (left, top)""" - body = driver.find_element_by_tag_name('body') + body = driver.find_element(By.TAG_NAME, 'body') + # The offset is from the center, not top-left. + x = - body.size['width'] / 2 + self.left + y = - body.size['height'] / 2 + self.top chain = ActionChains(driver) - chain.move_to_element_with_offset( - body, self.left, self.top).click().perform() + chain.move_to_element_with_offset(body, x, y).click().perform() @property def left(self): @@ -114,7 +116,7 @@ def __init__(self, element, fail_hard=False): def __call__(self, driver): if self.element.tag == 'select': # SPECIAL CASE: