From f982b28d979667346e56a7f363235274d69283dd Mon Sep 17 00:00:00 2001 From: Alexandra Date: Sun, 3 Jan 2016 20:41:43 +0200 Subject: [PATCH 1/5] implemented some elements location functions --- source/selenium.d | 44 +++++++++++++++++++++++++++++++++++++------- source/test.d | 18 +++++++++++++++++- 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/source/selenium.d b/source/selenium.d index 0b6af8f..ec83561 100755 --- a/source/selenium.d +++ b/source/selenium.d @@ -178,6 +178,15 @@ struct Cookie { } } +struct ElementLocator { + LocatorStrategy using; + string value; +} + +struct WebElement { + string ELEMENT; +} + struct SeleniumSession { string serverUrl; @@ -326,14 +335,35 @@ struct SeleniumSession { return this; } + auto deleteCookie(string name) { + DELETE("/cookie/" ~ name); + return this; + } + + auto source() { + return GET!string("/source"); + } + + auto title() { + return GET!string("/title"); + } + auto element(ElementLocator elem) { + return POST!WebElement("/element", elem); + } + + auto elements(ElementLocator elem) { + return POST!(WebElement[])("/elements", elem); + } + + auto activeElement() { + return POST!WebElement("/element/active"); + } + + auto elementFromElement(string initialElem, ElementLocator elem) { + return POST!WebElement("/element/" ~ initialElem ~ "/element", elem); + } /* -/session/:sessionId/cookie/:name -/session/:sessionId/source -/session/:sessionId/title -/session/:sessionId/element -/session/:sessionId/elements -/session/:sessionId/element/active /session/:sessionId/element/:id /session/:sessionId/element/:id/element /session/:sessionId/element/:id/elements @@ -470,7 +500,7 @@ private Json makeRequest(T)(HTTPMethod method, string path, T data) { Json result; bool done = false; - logInfo("REQUEST: %s %s %s", method, path, data.to!string); + logInfo("REQUEST: %s %s %s", method, path, data.serializeToJson.toPrettyString); requestHTTP(path, (scope req) { diff --git a/source/test.d b/source/test.d index 0009998..44751aa 100644 --- a/source/test.d +++ b/source/test.d @@ -11,7 +11,7 @@ unittest { auto url2 = "http://www.amazon.com/The-Boys-Boat-Americans-Olympics/dp/0143125478/"; auto session = SeleniumSession("http://127.0.0.1:4444/wd/hub", Capabilities.chrome); - +/+ session.timeouts(TimeoutType.script, 10_000); session.timeouts(TimeoutType.implicit, 10_000); session.timeouts(TimeoutType.pageLoad, 10_000); @@ -61,7 +61,23 @@ unittest { auto cookie = Cookie("test", "value"); session.setCookie(cookie); + session.deleteCookie("test"); session.deleteAllCookies; ++/ + assert(session.source != ""); + session.url("http://wfmu.org/playlists/LM"); + assert(session.title == "WFMU: This Is The Modern World with Trouble: Playlists and Archives"); + auto elem = ElementLocator(LocatorStrategy.ClassName, "ui-dialog"); + session.element(elem); + auto elem2 = ElementLocator(LocatorStrategy.CssSelector, ".showList ul"); + session.elements(elem2); + session.element(elem2); + + auto elem3 = ElementLocator(LocatorStrategy.TagName, "li"); + session.elementFromElement(session.element(elem2).ELEMENT, elem3); + + session.activeElement; + session.disconnect; } From 159a8d2074884191ee7d679e363d3be842a877f2 Mon Sep 17 00:00:00 2001 From: Alexandra Date: Mon, 4 Jan 2016 11:06:53 +0200 Subject: [PATCH 2/5] some more implementations for requests --- source/selenium.d | 86 +++++++++++++++++++++++++++++++++++++---------- source/test.d | 39 +++++++++++++++++++-- 2 files changed, 105 insertions(+), 20 deletions(-) diff --git a/source/selenium.d b/source/selenium.d index ec83561..2eb5626 100755 --- a/source/selenium.d +++ b/source/selenium.d @@ -348,35 +348,85 @@ struct SeleniumSession { return GET!string("/title"); } - auto element(ElementLocator elem) { - return POST!WebElement("/element", elem); + auto element(ElementLocator locator) { + return POST!WebElement("/element", locator); } - auto elements(ElementLocator elem) { - return POST!(WebElement[])("/elements", elem); + auto elements(ElementLocator locator) { + return POST!(WebElement[])("/elements", locator); } auto activeElement() { return POST!WebElement("/element/active"); } - auto elementFromElement(string initialElem, ElementLocator elem) { - return POST!WebElement("/element/" ~ initialElem ~ "/element", elem); + auto elementFromElement(string initialElemId, ElementLocator locator) { + return POST!WebElement("/element/" ~ initialElemId ~ "/element", locator); } + + auto elementsFromElement(string initialElemId, ElementLocator locator) { + return POST!(WebElement[])("/element/" ~ initialElemId ~ "/elements", locator); + } + + auto clickElement(string elementId) { + POST("/element/" ~ elementId ~ "/click"); + return this; + } + + auto submitElement(string elementId) { + POST("/element/" ~ elementId ~ "/submit"); + return this; + } + + auto elementText(string elementId) { + return GET!string("/element/" ~ elementId ~ "/text"); + } + + auto sendKeys(string elementId, string[] value) { + struct Body { + string[] value; + } + + POST("/element/" ~ elementId ~ "/value", Body(value)); + return this; + } + + auto sendKeysToActiveElement(string[] value) { + struct Body { + string[] value; + } + + POST("/keys", Body(value)); + return this; + } + + auto elementName(string elementId) { + return GET!string("/element/" ~ elementId ~ "/name"); + } + + auto clearElementValue(string elementId) { + POST("/element/" ~ elementId ~ "/clear"); + return this; + } + + auto elementSelected(string elementId) { + return GET!bool("/element/" ~ elementId ~ "/selected"); + } + + auto elementEnabled(string elementId) { + return GET!bool("/element/" ~ elementId ~ "/enabled"); + } + + auto elementValue(string elementId, string attribute) { + return GET!string("/element/" ~ elementId ~ "/attribute/" ~ attribute); + } + + auto elementEqualsOther(string firstElementId, string secondElementId) { + return GET!bool("/element/" ~ firstElementId ~ "/equals/" ~ secondElementId); + } + /* /session/:sessionId/element/:id -/session/:sessionId/element/:id/element -/session/:sessionId/element/:id/elements -/session/:sessionId/element/:id/click -/session/:sessionId/element/:id/submit -/session/:sessionId/element/:id/text -/session/:sessionId/element/:id/value -/session/:sessionId/keys -/session/:sessionId/element/:id/name -/session/:sessionId/element/:id/clear -/session/:sessionId/element/:id/selected -/session/:sessionId/element/:id/enabled -/session/:sessionId/element/:id/attribute/:name /session/:sessionId/element/:id/equals/:other /session/:sessionId/element/:id/displayed /session/:sessionId/element/:id/location diff --git a/source/test.d b/source/test.d index 44751aa..86fecc0 100644 --- a/source/test.d +++ b/source/test.d @@ -74,10 +74,45 @@ unittest { session.element(elem2); auto elem3 = ElementLocator(LocatorStrategy.TagName, "li"); - session.elementFromElement(session.element(elem2).ELEMENT, elem3); + session.elementsFromElement(session.element(elem2).ELEMENT, elem3); session.activeElement; + auto elem4 = ElementLocator(LocatorStrategy.LinkText, "See the playlist"); + session.clickElement(session.element(elem4).ELEMENT); + assert(session.url == "http://wfmu.org/playlists/shows/64336"); - session.disconnect; + session.url("http://szabobogdan.com/ro.php"); +/+ auto elem5 = ElementLocator(LocatorStrategy.ClassName, "mailForm"); + session.submitElement(session.element(elem5).ELEMENT); ++/ + auto elem6 = ElementLocator(LocatorStrategy.CssSelector, "#contact h2"); + assert(session.elementText(session.element(elem6).ELEMENT) == "Contact"); + + auto elem7 = ElementLocator(LocatorStrategy.Id, "formName"); + auto idElem7 = session.element(elem7).ELEMENT; + session.sendKeys(idElem7, ["a", "l", "e"]); + + session.sendKeysToActiveElement(["2", "t"]); + + session.elementValue(idElem7, "value"); + + assert(session.elementName(idElem7) == "input"); + + session.clearElementValue(idElem7); + assert(session.elementValue(idElem7, "value") == ""); + + session.url(url1); + auto elem8 = ElementLocator(LocatorStrategy.CssSelector, "#quantity option"); + auto idElem8 = session.element(elem8).ELEMENT; + assert(session.elementSelected(idElem8)); + + assert(session.elementEnabled(idElem8)); + + auto elem9 = ElementLocator(LocatorStrategy.CssSelector, "#quantity"); + auto elem9bis = ElementLocator(LocatorStrategy.XPath, ".//*[@id='quantity']"); + auto idElem9 = session.element(elem9).ELEMENT; + auto idElem9bis = session.element(elem9bis).ELEMENT; + assert(session.elementEqualsOther(idElem9, idElem9bis)); + //session.disconnect; } From 7b4a1e9ac753111a28e524b78c9e5a3664121f22 Mon Sep 17 00:00:00 2001 From: Alexandra Date: Thu, 7 Jan 2016 14:19:22 +0200 Subject: [PATCH 3/5] more bindings implemented --- source/selenium.d | 64 ++++++++++++++++++++++++++++++++++++++++------- source/test.d | 36 ++++++++++++++++++++------ 2 files changed, 84 insertions(+), 16 deletions(-) diff --git a/source/selenium.d b/source/selenium.d index 2eb5626..a4f8be4 100755 --- a/source/selenium.d +++ b/source/selenium.d @@ -142,6 +142,11 @@ enum TimeoutType: string { pageLoad = "page load" } +enum Orientation: string { + landscape = "LANDSCAPE", + portrait = "PORTRAIT" +} + struct SessionResponse(T) { @optional { @@ -274,11 +279,16 @@ struct SeleniumSession { return this; } - auto frame(Json id = null) { + auto frame(string id) { POST("/frame", ["id": id]); return this; } + auto frame(WebElement element) { + POST("/frame", element); + return this; + } + auto frameParent() { POST("/frame/parent"); return this; @@ -425,15 +435,51 @@ struct SeleniumSession { return GET!bool("/element/" ~ firstElementId ~ "/equals/" ~ secondElementId); } + auto elementDisplayed(string elementId) { + return GET!bool("/element/" ~ elementId ~ "/displayed"); + } + + auto elementLocation(string elementId) { + return GET!Position("/element/" ~ elementId ~ "/location"); + } + + auto elementLocationInView(string elementId) { + return GET!Position("/element/" ~ elementId ~ "/location_in_view"); + } + + auto elementSize(string elementId) { + return GET!Size("/element/" ~ elementId ~ "/size"); + } + + auto elementCssPropertyName(string elementId, string propertyName) { + return GET!string("/element/" ~ elementId ~ "/css/" ~ propertyName); + } + + auto orientation() { + return GET!Orientation("/orientation"); + } + + auto setOrientation(Orientation orientation) { + struct Body { + Orientation orientation; + } + + return POST("/orientation", Body(orientation)); + } + + auto alertText() { + return GET!string("/alert_text"); + } + + auto setPromptText(string text) { + POST("/alert_text", ["text": text]); + return this; + } + + /* -/session/:sessionId/element/:id -/session/:sessionId/element/:id/equals/:other -/session/:sessionId/element/:id/displayed -/session/:sessionId/element/:id/location -/session/:sessionId/element/:id/location_in_view -/session/:sessionId/element/:id/size -/session/:sessionId/element/:id/css/:propertyName -/session/:sessionId/orientation +/session/:sessionId/element/:id - not yet implemented in Selenium + /session/:sessionId/alert_text /session/:sessionId/accept_alert /session/:sessionId/dismiss_alert diff --git a/source/test.d b/source/test.d index 86fecc0..df758fc 100644 --- a/source/test.d +++ b/source/test.d @@ -11,11 +11,11 @@ unittest { auto url2 = "http://www.amazon.com/The-Boys-Boat-Americans-Olympics/dp/0143125478/"; auto session = SeleniumSession("http://127.0.0.1:4444/wd/hub", Capabilities.chrome); -/+ + session.timeouts(TimeoutType.script, 10_000); session.timeouts(TimeoutType.implicit, 10_000); session.timeouts(TimeoutType.pageLoad, 10_000); - +/+ string handle = session.windowHandle; writeln("windowHandle: ", handle); writeln("windowHandles: ", session.windowHandles); @@ -63,12 +63,15 @@ unittest { session.setCookie(cookie); session.deleteCookie("test"); session.deleteAllCookies; -+/ + assert(session.source != ""); + session.url("http://wfmu.org/playlists/LM"); assert(session.title == "WFMU: This Is The Modern World with Trouble: Playlists and Archives"); + auto elem = ElementLocator(LocatorStrategy.ClassName, "ui-dialog"); session.element(elem); + auto elem2 = ElementLocator(LocatorStrategy.CssSelector, ".showList ul"); session.elements(elem2); session.element(elem2); @@ -78,14 +81,17 @@ unittest { session.activeElement; - auto elem4 = ElementLocator(LocatorStrategy.LinkText, "See the playlist"); + auto elem4 = ElementLocator(LocatorStrategy.LinkText, "View Trouble's profile"); session.clickElement(session.element(elem4).ELEMENT); - assert(session.url == "http://wfmu.org/playlists/shows/64336"); + assert(session.url == "http://www.wfmu.org/profile/686399632/Trouble"); session.url("http://szabobogdan.com/ro.php"); -/+ auto elem5 = ElementLocator(LocatorStrategy.ClassName, "mailForm"); - session.submitElement(session.element(elem5).ELEMENT); + auto elem5 = ElementLocator(LocatorStrategy.ClassName, "mailForm"); +// session.submitElement(session.element(elem5).ELEMENT); +// session.wait(1000); +// session.alertText(); +/ +/* auto elem6 = ElementLocator(LocatorStrategy.CssSelector, "#contact h2"); assert(session.elementText(session.element(elem6).ELEMENT) == "Contact"); @@ -114,5 +120,21 @@ unittest { auto idElem9 = session.element(elem9).ELEMENT; auto idElem9bis = session.element(elem9bis).ELEMENT; assert(session.elementEqualsOther(idElem9, idElem9bis)); + + assert(session.elementDisplayed(idElem9) == true); + + session.elementLocation(idElem9); + session.elementLocationInView(idElem9); + session.elementSize(idElem9); + session.elementCssPropertyName(idElem9, "display"); +*/ + //session.setOrientation(Orientation.landscape); + //assert(session.orientation == Orientation.landscape); + + + session.executeAsync!string(`prompt("Please enter your name");`); + session.wait(1000); + session.setPromptText("test"); + //session.disconnect; } From bc274cb997adf43b2564e6dd7ef99b82d1b545fe Mon Sep 17 00:00:00 2001 From: Szabo Bogdan Date: Thu, 7 Jan 2016 22:21:52 +0200 Subject: [PATCH 4/5] Added alert, mouse, touch and location --- source/selenium.d | 152 ++++++++++++++++++++++++++++++++++++++++------ source/test.d | 39 ++++++++++-- 2 files changed, 168 insertions(+), 23 deletions(-) diff --git a/source/selenium.d b/source/selenium.d index a4f8be4..8ae9438 100755 --- a/source/selenium.d +++ b/source/selenium.d @@ -147,6 +147,12 @@ enum Orientation: string { portrait = "PORTRAIT" } +enum MouseButton: int { + left = 0, + middle = 1, + right = 2 +} + struct SessionResponse(T) { @optional { @@ -192,6 +198,12 @@ struct WebElement { string ELEMENT; } +struct GeoLocation(T) { + T latitude; + T longitude; + T altitude; +} + struct SeleniumSession { string serverUrl; @@ -476,29 +488,131 @@ struct SeleniumSession { return this; } + auto acceptAlert() { + POST("/accept_alert"); + return this; + } + + auto dismissAlert() { + POST("/dismiss_alert"); + return this; + } + auto moveTo(Position position) { + POST("/moveto", ["xoffset": position.x, "yoffset": position.y]); + return this; + } + + auto moveTo(string elementId) { + POST("/moveto", ["element": elementId]); + return this; + } + + auto moveTo(string elementId, Position position) { + struct Body { + string element; + long xoffset; + long yoffset; + } + + POST("/moveto", Body(elementId, position.x, position.y)); + return this; + } + + auto click(MouseButton button = MouseButton.left) { + POST("/click", ["button": button]); + return this; + } + + auto buttonDown(MouseButton button = MouseButton.left) { + POST("/buttondown", ["button": button]); + return this; + } + + auto buttonUp(MouseButton button = MouseButton.left) { + POST("/buttonup", ["button": button]); + return this; + } + + auto doubleClick() { + POST("/doubleclick"); + return this; + } + + auto touchClick(string elementId) { + POST("/touch/click", ["element": elementId]); + return this; + } + + auto touchDown(Position position) { + POST("/touch/down", ["x": position.x, "y": position.y]); + return this; + } + + auto touchUp(Position position) { + POST("/touch/up", ["x": position.x, "y": position.y]); + return this; + } + + auto touchMove(Position position) { + POST("/touch/move", ["x": position.x, "y": position.y]); + return this; + } + + auto touchScroll(string elementId, Position position) { + struct Body { + string element; + long xoffset; + long yoffset; + } + + POST("/touch/scroll", Body(elementId, position.x, position.y)); + return this; + } + + auto touchScroll(Position position) { + POST("/touch/scroll", ["xoffset": position.x, "yoffset": position.y]); + return this; + } + + auto touchDoubleClick(string elementId) { + POST("/touch/doubleclick", ["element": elementId]); + return this; + } + + auto touchLongClick(string elementId) { + POST("/touch/longclick", ["element": elementId]); + return this; + } + + auto touchFlick(string elementId, Position position, long speed) { + struct Body { + string element; + long xoffset; + long yoffset; + long speed; + } + + POST("/touch/flick", Body(elementId, position.x, position.y, speed)); + return this; + } + + auto touchFlick(long xSpeed, long ySpeed) { + POST("/touch/flick", [ "xspeed": xSpeed, "yspeed": ySpeed ]); + return this; + } + + auto geoLocation() { + return GET!(GeoLocation!double)("/location"); + } + + auto setGeoLocation(T)(T location) { + POST("/location", ["location": location]); + return this; + } /* /session/:sessionId/element/:id - not yet implemented in Selenium -/session/:sessionId/alert_text -/session/:sessionId/accept_alert -/session/:sessionId/dismiss_alert -/session/:sessionId/moveto -/session/:sessionId/click -/session/:sessionId/buttondown -/session/:sessionId/buttonup -/session/:sessionId/doubleclick -/session/:sessionId/touch/click -/session/:sessionId/touch/down -/session/:sessionId/touch/up -session/:sessionId/touch/move -session/:sessionId/touch/scroll -session/:sessionId/touch/scroll -session/:sessionId/touch/doubleclick -session/:sessionId/touch/longclick -session/:sessionId/touch/flick -session/:sessionId/touch/flick -/session/:sessionId/location /session/:sessionId/local_storage /session/:sessionId/local_storage/key/:key /session/:sessionId/local_storage/size diff --git a/source/test.d b/source/test.d index df758fc..ae4f911 100644 --- a/source/test.d +++ b/source/test.d @@ -107,7 +107,7 @@ unittest { session.clearElementValue(idElem7); assert(session.elementValue(idElem7, "value") == ""); - +*/ session.url(url1); auto elem8 = ElementLocator(LocatorStrategy.CssSelector, "#quantity option"); auto idElem8 = session.element(elem8).ELEMENT; @@ -127,14 +127,45 @@ unittest { session.elementLocationInView(idElem9); session.elementSize(idElem9); session.elementCssPropertyName(idElem9, "display"); -*/ + //session.setOrientation(Orientation.landscape); //assert(session.orientation == Orientation.landscape); - +/* + session.executeAsync!string(`prompt("Please enter your name");`); + session.wait(1000); + session.setPromptText("test").acceptAlert; session.executeAsync!string(`prompt("Please enter your name");`); session.wait(1000); - session.setPromptText("test"); + session.dismissAlert;*/ + + session.moveTo(Position(100, 100)); + session.moveTo(idElem9); + session.moveTo(idElem9, Position(100, 100)); + + session.click(MouseButton.right); + + session.buttonDown; + session.buttonUp; + session.doubleClick; + +/* It's not working with chrome driver. It's too advanced. + session.touchClick(idElem9); + session.touchDown(Position(100, 100)); + session.touchUp(Position(100, 100)); + session.touchMove(Position(200, 200)); + session.touchScroll(idElem9, Position(200, 200)); + session.touchScroll(Position(200, 200)); + session.touchDoubleClick(idElem9); + session.touchLongClick(idElem9); + session.touchFlick(idElem9, Position(200, 200), 10); + session.touchFlick(100, 100);*/ + + session.setGeoLocation(GeoLocation!double(12.3, 13.3, 34.4)) + + //Web driver bug. It does not work. + //session.geoLocation(); + //session.disconnect; } From fa9c1b30ef1e95a126da3155d1bde48e48405f35 Mon Sep 17 00:00:00 2001 From: Szabo Bogdan Date: Sun, 10 Jan 2016 18:32:03 +0200 Subject: [PATCH 5/5] Done with http handlers --- source/selenium.d | 144 ++++++++++++++++++++++++++++++++++++++-------- source/test.d | 42 ++++++++++---- 2 files changed, 150 insertions(+), 36 deletions(-) diff --git a/source/selenium.d b/source/selenium.d index 8ae9438..aa269ab 100755 --- a/source/selenium.d +++ b/source/selenium.d @@ -98,6 +98,48 @@ enum AlertBehaviour: string { ignore = "ignore" } +enum LogType: string { + client = "client", + driver = "driver", + browser = "browser", + server = "server" +} + +enum TimeoutType: string { + script = "script", + implicit = "implicit", + pageLoad = "page load" +} + +enum Orientation: string { + landscape = "LANDSCAPE", + portrait = "PORTRAIT" +} + +enum MouseButton: int { + left = 0, + middle = 1, + right = 2 +} + +enum LogLevel: string { + ALL = "ALL", + DEBUG = "DEBUG", + INFO = "INFO", + WARNING = "WARNING", + SEVERE = "SEVERE", + OFF = "OFF" +} + +enum CacheStatus { + uncached = 0, + idle = 1, + checking = 2, + downloading = 3, + update_ready = 4, + obsolete = 5 +} + struct Capabilities { @optional { Browser browserName; @@ -136,23 +178,6 @@ struct Capabilities { } } -enum TimeoutType: string { - script = "script", - implicit = "implicit", - pageLoad = "page load" -} - -enum Orientation: string { - landscape = "LANDSCAPE", - portrait = "PORTRAIT" -} - -enum MouseButton: int { - left = 0, - middle = 1, - right = 2 -} - struct SessionResponse(T) { @optional { @@ -204,6 +229,12 @@ struct GeoLocation(T) { T altitude; } +struct LogEntry { + long timestamp; + LogLevel level; + string message; +} + struct SeleniumSession { string serverUrl; @@ -296,6 +327,11 @@ struct SeleniumSession { return this; } + auto frame(long id) { + POST("/frame", ["id": id]); + return this; + } + auto frame(WebElement element) { POST("/frame", element); return this; @@ -610,16 +646,76 @@ struct SeleniumSession { POST("/location", ["location": location]); return this; } + + auto localStorage() { + return GET!(string[])("/local_storage"); + } + + auto setLocalStorage(string key, string value) { + POST("/local_storage", ["key": key, "value": value]); + return this; + } + + auto deleteLocalStorage() { + DELETE("/local_storage"); + return this; + } + + auto localStorage(string key) { + return GET!(string)("/local_storage/key/" ~ key); + } + + auto deleteLocalStorage(string key) { + DELETE("/local_storage/key/" ~ key); + return this; + } + + auto localStorageSize() { + return GET!(long)("/local_storage/size"); + } + + auto sessionStorage() { + return GET!(string[])("/session_storage"); + } + + auto setSessionStorage(string key, string value) { + POST("/session_storage", ["key": key, "value": value]); + return this; + } + + auto deleteSessionStorage() { + DELETE("/session_storage"); + return this; + } + + auto sessionStorage(string key) { + return GET!(string)("/session_storage/key/" ~ key); + } + + auto deleteSessionStorage(string key) { + DELETE("/session_storage/key/" ~ key); + return this; + } + + auto sessionStorageSize() { + return GET!(long)("/session_storage/size"); + } + + auto log(LogType logType) { + return POST!(LogEntry[])("/log", ["type": logType]); + } + + auto logTypes() { + return GET!(string[])("/log/types"); + } + + auto applicationCacheStatus() { + return GET!CacheStatus("/application_cache/status"); + } + /* /session/:sessionId/element/:id - not yet implemented in Selenium -/session/:sessionId/local_storage -/session/:sessionId/local_storage/key/:key -/session/:sessionId/local_storage/size -/session/:sessionId/session_storage -/session/:sessionId/session_storage/key/:key -/session/:sessionId/session_storage/size -/session/:sessionId/log /session/:sessionId/log/types /session/:sessionId/application_cache/status*/ diff --git a/source/test.d b/source/test.d index ae4f911..f05b17d 100644 --- a/source/test.d +++ b/source/test.d @@ -15,7 +15,7 @@ unittest { session.timeouts(TimeoutType.script, 10_000); session.timeouts(TimeoutType.implicit, 10_000); session.timeouts(TimeoutType.pageLoad, 10_000); -/+ + string handle = session.windowHandle; writeln("windowHandle: ", handle); writeln("windowHandles: ", session.windowHandles); @@ -45,7 +45,7 @@ unittest { writeln("active_engine: ", session.imeActivate); */ - session.frame; + session.frame(1); //session.frameParent; //session.selectWindow("testOpen"); //session.closeCurrentWindow(); @@ -83,15 +83,16 @@ unittest { auto elem4 = ElementLocator(LocatorStrategy.LinkText, "View Trouble's profile"); session.clickElement(session.element(elem4).ELEMENT); + session.wait(1000); assert(session.url == "http://www.wfmu.org/profile/686399632/Trouble"); session.url("http://szabobogdan.com/ro.php"); auto elem5 = ElementLocator(LocatorStrategy.ClassName, "mailForm"); -// session.submitElement(session.element(elem5).ELEMENT); -// session.wait(1000); -// session.alertText(); -+/ -/* + session.submitElement(session.element(elem5).ELEMENT); + session.wait(1000); + session.alertText(); + session.acceptAlert(); + auto elem6 = ElementLocator(LocatorStrategy.CssSelector, "#contact h2"); assert(session.elementText(session.element(elem6).ELEMENT) == "Contact"); @@ -107,7 +108,7 @@ unittest { session.clearElementValue(idElem7); assert(session.elementValue(idElem7, "value") == ""); -*/ + session.url(url1); auto elem8 = ElementLocator(LocatorStrategy.CssSelector, "#quantity option"); auto idElem8 = session.element(elem8).ELEMENT; @@ -130,14 +131,14 @@ unittest { //session.setOrientation(Orientation.landscape); //assert(session.orientation == Orientation.landscape); -/* + session.executeAsync!string(`prompt("Please enter your name");`); session.wait(1000); session.setPromptText("test").acceptAlert; session.executeAsync!string(`prompt("Please enter your name");`); session.wait(1000); - session.dismissAlert;*/ + session.dismissAlert; session.moveTo(Position(100, 100)); session.moveTo(idElem9); @@ -161,11 +162,28 @@ unittest { session.touchFlick(idElem9, Position(200, 200), 10); session.touchFlick(100, 100);*/ - session.setGeoLocation(GeoLocation!double(12.3, 13.3, 34.4)) + session.setGeoLocation(GeoLocation!double(12.3, 13.3, 34.4)); //Web driver bug. It does not work. //session.geoLocation(); + session.setLocalStorage("key1", "val1"); + session.localStorage(); + session.localStorage("key1"); + session.deleteLocalStorage("key1"); + session.deleteLocalStorage(); + session.localStorageSize(); + + session.setSessionStorage("key2", "val2"); + session.sessionStorage("key2"); + session.sessionStorage(); + session.deleteSessionStorage("key2"); + session.deleteSessionStorage(); + + session.log(LogType.browser); + session.logTypes(); + + //session.applicationCacheStatus(); - //session.disconnect; + session.disconnect; }