History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: SRC-514
Type: Bug Bug
Status: Open Open
Priority: Minor Minor
Assignee: Unassigned
Reporter: Kent Davidson
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Selenium Remote Control

getString function in PHP library returns false when it should return an empty string

Created: 22/Aug/08 10:24 AM   Updated: 22/Aug/08 10:27 AM
Component/s: Client Driver - PHP
Affects Version/s: 0.9.2
Fix Version/s: None

Original Estimate: 0.08h Remaining Estimate: 0.08h Time Spent: Unknown
Environment: All


 Description  « Hide
substr in PHP has a funny side-effect such that:

substr("OK,",3) === false

Which causes errors. Fix is as follows:

private function getString($verb, $args = array())
    {
        try {
            $result = $this->doCommand($verb, $args);
        } catch (SeleniumException $e) {
            return $e;
        }
        if (strlen($result) === 3) return "";
        return substr($result, 3);
    }

Note that you could also fix

http://jira.openqa.org/browse/SRC-425

as well as follows:

private function getString($verb, $args = array())
    {
        $result = $this->doCommand($verb, $args);
        if (strlen($result) === 3) return "";
        return substr($result, 3);
    }

Letting the exception be passed up the chain to be handled. I'd also recommend letting this be public to enable overriding it.

 All   Comments   Work Log   Change History      Sort Order:
Kent Davidson - 22/Aug/08 10:27 AM
The relevance comes when doing "getValue($locator)" and you want to ensure a particular field is empty. I have added functionality as such:

    public function assertValue($locator, $value)
    {
     $site_value = $this->getValue($locator);
     if ($site_value !== $value) {
     $this->failed("Element $locator does not match expected value \"$value\" (".gettype($value)."): \"$site_value\" (".gettype($site_value).")");
     }
    }

when checking inputs which should be empty.