Difference between revisions of "Basic Functions of a Wiki"
(→Notes) |
|||
| Line 51: | Line 51: | ||
* whole page text, not just one section | * whole page text, not just one section | ||
* look for more duplication in code | * look for more duplication in code | ||
| + | |||
| + | === getText === | ||
| + | public function getText($locator) | ||
| + | { | ||
| + | return $this->selenium->getText($locator); | ||
| + | } | ||
| + | Ted Ernst 3/14/07 9:32 AM | ||
| + | public function getText($locator) | ||
| + | { | ||
| + | return $this->getString("getText", array($locator)); | ||
| + | } | ||
| + | Ted Ernst 3/14/07 9:33 AM | ||
| + | private function getString($verb, $args = array()) | ||
| + | { | ||
| + | try { | ||
| + | $result = $this->doCommand($verb, $args); | ||
| + | } catch (Testing_Selenium_Exception $e) { | ||
| + | return $e; | ||
| + | } | ||
| + | return substr($result, 3); | ||
| + | } | ||
| + | Ted Ernst 3/14/07 9:38 AM | ||
| + | private function doCommand($verb, $args = array()) | ||
| + | { | ||
| + | $url = sprintf('http://%s:%s/selenium-server/driver/?cmd=%s', $this->host, $this->port, urlencode($verb)); | ||
| + | for ($i = 0; $i < count($args); $i++) { | ||
| + | $argNum = strval($i + 1); | ||
| + | $url .= sprintf('&%s=%s', $argNum, urlencode(trim($args[$i]))); | ||
| + | } | ||
| + | |||
| + | if (isset($this->sessionId)) { | ||
| + | $url .= sprintf('&%s=%s', 'sessionId', $this->sessionId); | ||
| + | } | ||
| + | if ($this->driver == 'curl') { | ||
| + | $response = $this->useCurl($verb, $args, $url); | ||
| + | } else { | ||
| + | $response = $this->useNative($verb, $args, $url); | ||
| + | } | ||
| + | |||
| + | if (!preg_match('/^OK/', $response)) { | ||
| + | throw new Testing_Selenium_Exception('The Response of the Selenium RC is invalid: ' . $response); | ||
| + | } | ||
| + | return $response; | ||
| + | } | ||
| + | |||
| + | |||
[[Category:Acceptance Tests]] | [[Category:Acceptance Tests]] | ||
Revision as of 14:41, 14 March 2007
each test independent of the others? can we test preview or save if edit isn't working?
- edit
- logged in & not logged in, click the "edit" link at the top & "type" the "action=edit" url & click section edit & type section edit url
- verify the textarea exists
- verify the textarea contents are correct
- verify that typing works
- logged in & not logged in, click the "edit" link at the top & "type" the "action=edit" url & click section edit & type section edit url
- save
- in edit mode, click the "Save page" button
- verify that the page saves
- we're now NOT in edit mode
- the contents of the page are what we expect
- preview
- in edit mode, click the "Show preview" button
- the page shows both the contents of the page in html AND the textarea we're editing
Contents
Next Actions
- need to carefully think through edit tests to make sure they cannot pass when they shouldn't - all 8 tests now pass!
- CFLN issue very interesting - I'm writing this
$sectionOne="==first section==" .chr(13).chr(10). "test text in page $testPage $timestamp";and then getting this from the test runner:
Failed asserting that <string:==first section== test text in page AboutUsTest.com 1173799512> contains "==first section== test text in page AboutUsTest.com 1173799512".
Done
- created files basic_wiki_functions_acceptance_test.sh & BasicWikiFunctionsTest.php
- testEditLinkWholePageIP() & testEditLinkWholePageLogin() both call editLinkWholePage() which does the actual work - the only difference is the login one logs in
- testEditLinkSectionIP() & testEditLinkSectionLogin() both call editLinkSection() - same as above
- basic structure of the file is complete now with 8 tests in two categories, logged in & IP; calling 4 functions in two categories, whole page or section; calling 2 functions in two categories, edit link or type edit URL; call DoTest(), so it's something like this
- doTest
- editLink
- editLinkWholePage
- IP
- logged in
- editLinkSection
- IP
- logged in
- editLinkWholePage
- editURL
- editURLWholePage
- IP
- logged in
- editURLSection
- IP
- logged in
- editURLWholePage
- editLink
- doTest
Notes
- carriage return line feed issue
- linux uses LF only, mac uses CR only, win uses CRLF [1]
- What do I do about this?
- What happens if we use CRLF ( chr(13).chr(10) )?
- whole page text, not just one section
- look for more duplication in code
getText
public function getText($locator) { return $this->selenium->getText($locator); } Ted Ernst 3/14/07 9:32 AM public function getText($locator) { return $this->getString("getText", array($locator)); } Ted Ernst 3/14/07 9:33 AM private function getString($verb, $args = array()) { try { $result = $this->doCommand($verb, $args); } catch (Testing_Selenium_Exception $e) { return $e; } return substr($result, 3); } Ted Ernst 3/14/07 9:38 AM private function doCommand($verb, $args = array()) { $url = sprintf('http://%s:%s/selenium-server/driver/?cmd=%s', $this->host, $this->port, urlencode($verb)); for ($i = 0; $i sessionId)) { $url .= sprintf('&%s=%s', 'sessionId', $this->sessionId); } if ($this->driver == 'curl') { $response = $this->useCurl($verb, $args, $url); } else { $response = $this->useNative($verb, $args, $url); }
if (!preg_match('/^OK/', $response)) { throw new Testing_Selenium_Exception('The Response of the Selenium RC is invalid: ' . $response); } return $response; }
