Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@dataProvider with selenium #304

Open
jessicakryan opened this issue Apr 28, 2014 · 2 comments
Open

@dataProvider with selenium #304

jessicakryan opened this issue Apr 28, 2014 · 2 comments

Comments

@jessicakryan
Copy link

Hi,
Just wondering if anyone can help me. I am trying to run a Login test using the dataProvider annotation (my current set up is below). The test runs as expected and fills out the username and password fields correctly, however the output shows that the test failed with the following error message
testLoginFail with data set #1() does not exist. If anyone can help me out with this, it would be much appreciated.

/**
 * Constructor - initialise the web driver session
 */ 

public function __construct($name = NULL, array $data = array(), $dataName = '') {
parent::__construct($name, $data, $dataName);
...
/**
* Tests the unsuccessful login of a user
* @dataProvider userDataProvider
*/
public function testLoginFail($email, $password) {
//Create objects required by this test
$userAction = new UserAction($this);

    //Perform login action
    $userAction->endUserLogin($email, $password);

}

public function userDataProvider() {
return array(
array('afakeemail@gmail.com', 'Password'),
array('anotheremail@gmail.com', 'Password')
);
}

@herrwalter
Copy link

If you use the __construct method in your testsetup, you won't be able to use a dataProvider.

You should use the setUp method, which will be called before every test.
the setUpBeforeClass will be called before class instantiation.

@jessicakryan
Copy link
Author

Firstly thanks for your response. Sorry I should have mentioned I also have the setUp method in the same file as the constructor, as below;

//===============
/*
* setup - add pre test run tasks
*/
public function setUp() {
parent::setUp();
}
//================

The parent setUp class is located in the WebDriverTestCase.php file and is as follows
//================
public function setUp()
{
$caps = $this->getDesiredCapabilities();
$this->setBrowserUrl('');
if (!isset($caps['name'])) {
$caps['name'] = get_called_class().'::'.$this->getName();
$this->setDesiredCapabilities($caps);
}
}
//===============

Also you say I won't be able to use a dataProvider with the __construct method present but it seems to run fine and actually loads the page, inputs the email and password fields and then submits them but I get the error as stated above (data set #1() does not exist). Could there be any other reason for this/ am I missing something from my setUp method?

Again any help would be much appreciated.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants