From 728392587118a818a4af50da244900105c1fc15f Mon Sep 17 00:00:00 2001 From: azyth Date: Sun, 26 Apr 2015 15:17:19 -0400 Subject: [PATCH 1/2] set up, but not working --- tests/functional/config/behat.yml | 2 +- tests/functional/features/CodeView.feature | 2 +- .../features/contexts/AMainPageUITrait.php | 16 +++++++++------- .../features/contexts/FeatureContext.php | 10 ++++++++++ 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/tests/functional/config/behat.yml b/tests/functional/config/behat.yml index fc14b92dc..300918bf3 100644 --- a/tests/functional/config/behat.yml +++ b/tests/functional/config/behat.yml @@ -4,7 +4,7 @@ default: pretty: true extensions: Behat\MinkExtension: - base_url: 'http://localhost/' + base_url: 'http://blockly.codebender.cc/' files_path: %paths.base%/../../fixtures/ javascript_session: selenium_session browser_name: firefox diff --git a/tests/functional/features/CodeView.feature b/tests/functional/features/CodeView.feature index 7974057aa..64655d1bb 100644 --- a/tests/functional/features/CodeView.feature +++ b/tests/functional/features/CodeView.feature @@ -14,7 +14,7 @@ Feature: Viewing code or blocks When I click on the "Arduino" button Then I should see code - @wip + @wip @john Scenario: Block view blocks menu displays Given I am on the homepage When I click on the "Blocks" button diff --git a/tests/functional/features/contexts/AMainPageUITrait.php b/tests/functional/features/contexts/AMainPageUITrait.php index d11b85dc4..718c2d1fd 100644 --- a/tests/functional/features/contexts/AMainPageUITrait.php +++ b/tests/functional/features/contexts/AMainPageUITrait.php @@ -47,13 +47,15 @@ public function theCodeOnThePageShouldBeReset() \PHPUnit_Framework_Assert::assertTrue(strcmp($pageCode, $defaultCode) == 0, $errorMsg); } - /** - * @Then /^the blocks menu displays$/ - */ - public function theBlocksMenuDisplays() - { - throw new PendingException('- Figure out how to get the Blocks Menu via XPath.'); - } +// /** +// * @Then /^the blocks menu displays$/ +// */ +// public function theBlocksMenuDisplays() +// { +// +// \PHPUnit_Framework_Assert::ass +// throw new PendingException('- Figure out how to get the Blocks Menu via XPath.'); +// } /** * @When /^I place a block$/ diff --git a/tests/functional/features/contexts/FeatureContext.php b/tests/functional/features/contexts/FeatureContext.php index 9540c78bd..f6a042ee4 100644 --- a/tests/functional/features/contexts/FeatureContext.php +++ b/tests/functional/features/contexts/FeatureContext.php @@ -144,4 +144,14 @@ public function cleanupNewlinesAndWhitespace($file) { protected function jqueryWait($duration = 1000) { $this->getSession()->wait($duration, "(0 === jQuery.active && 0 === jQuery(':animated').length)"); } + /** + * @Then /^the blocks menu displays$/ + */ + public function theBlocksMenuDisplays() + { + $iframe = $this->getXPath('//*[@id="content_blocks"]'); + $this->assertElementOnPage($iframe->getXPath('/html/body/svg/g[2]/g[2]')); + + + } } From 8869fd7d87b1c0d78700536499256f46a6f37d14 Mon Sep 17 00:00:00 2001 From: azyth Date: Sun, 26 Apr 2015 18:23:03 -0400 Subject: [PATCH 2/2] accessing the driver to switch frames --- .../functional/features/contexts/FeatureContext.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/functional/features/contexts/FeatureContext.php b/tests/functional/features/contexts/FeatureContext.php index f6a042ee4..f2f80f6c1 100644 --- a/tests/functional/features/contexts/FeatureContext.php +++ b/tests/functional/features/contexts/FeatureContext.php @@ -149,8 +149,17 @@ protected function jqueryWait($duration = 1000) { */ public function theBlocksMenuDisplays() { - $iframe = $this->getXPath('//*[@id="content_blocks"]'); - $this->assertElementOnPage($iframe->getXPath('/html/body/svg/g[2]/g[2]')); +// var iframe = document.getElementsByTagName("iframe")[0]; +// var theFirstSpan = document.evaluate('//span', iframe.contentDocument, +// null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue + +// selenium web driver + $driver = $this->getSession()->getDriver(); + $iframe = $driver->find('//*[@id="content_blocks"]')[0]; + $driver->switchToIFrame('//*[@id="content_blocks"]'); +// $iframe = $this->getXPath('//*[@id="content_blocks"]'); + $this->assertElementOnPage($this->getXPath('//html/body/svg/g[2]/g[2]')); + }