mercredi 2 décembre 2015

Selenium browser window size

I'm new at using selenium. I have downloaded the Selenium Standalone Server and successfully got it running by typing

java -jar selenium-server-standalone-2.14.0.jar

into the command line.

After running

 phpunit.bat

from the command line, all of my tests will pass as expected except for one unless I manually maximize the FireFox browser window that automatically is opened during the testing process.

While the tests are running, when the FireFox browser window opens, if I don't maximize that window while my login test is running, then that test will fail and somehow redirect to a unexpected page on my website. If I do maximize the window before the test completes, the "login" button gets clicked as expected, the correct page gets loaded, and the test passes.

Thus, I'm wondering if there is a way to change the settings somewhere so that the FireFox browser would just open maximized while the tests are running?

I've googled around and discovered some various code snippets that might help me, but I'm not sure where the PHP version of this code is or where to put some similar code for the version of Selenium I'm using (the Selenium Standalone Server):

# repositioning and resizing browser window:
driver.manage.window.move_to(300, 400)
driver.manage.window.resize_to(500, 800)
driver.manage.window.maximize

or this which is C#, but I need PHP and don't know where to find the right code or where to put it:

driver.Manage().Window.Maximize();   

Here is the code for the login Selenium test in question (using Laracasts/Integrated) from my tests/SeleniumTest.php file:

    /**
     * Tests to see if the login page loads
     */
    public function testToSeeIfLoginLoads()
    {
        $this->visit('/login')
            ->see('Login')->see('Email Address')->see('Password')
            ->type('myemail@email.com', 'email')->type('mypassword', 'password')
            ->waitForElement('log_in')
           ->click('log_in')
            ->waitForElement('table_summary')
            ->see('Complete Course Summary');
    }

Any suggestions are appreciated, including if using QUnit or Selenium IDE might be easier. Thank you.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire