Magium
The magium/magium library is a base library that all components require. It contains a number of helper functions to make your Selenium tests easier to manage. The components in this library can be used on any website.
Installing magium/magium is as simple as running a simple composer command.
composer require magium/magium
Most of the functionality is fairly basic, but sets the stage components such as magium/magento
. But
that said you can still do some basic things like navigation around the site or even some placement assertions.
class AssertionTest extends Magium\AbstractTestCase { public function testElementPosition() { $this->commandOpen('http://example.com/'); $topElement = $this->byId('top-left'); $bottomElement = $this->byId('bottom-left'); $assertion = $this->getAssertion(IsBelow::ASSERTION); $assertion->setAboveElement($topElement); $assertion->setBelowElement($bottomElement); $assertion->assert(); // asserts that the above element is positionally above the below element } }
Navigation is pretty easy too
class NavigationTest extends Magium\AbstractTestCase { public function testAboutUsNavigation() { $this->commandOpen('http://example.com/'); $this->byText('About Us')->click(); $this->assertTitleContains('About Us'); } }
So, while most of the functionality in Magium is intended to be plumbing for other libraries it is really, really, really easy to get started. In fact, once Selenium server is set up (check out the home page for instructions), you should be writing simple tests in 5 minutes.