GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — codeception.github.com/_posts/2012-09-24-locator.markdown at master · samdark/codeception.github.com

Expand file tree

/

2012-09-24-locator.markdown

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
60 lines (42 loc) · 1.79 KB
/

2012-09-24-locator.markdown

Copy path

File metadata and controls

60 lines (42 loc) · 1.79 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions
layout post
title The Locator Class
date 2012-09-23 18:03:50 -0700

In the latest Codeception 1.1.4 new Locator class was introduced. Basically it should simplify your life in writing complex XPath or CSS locators. Right now it has minimal, yet useful functionality.

Combine

Locator can combine two locators using OR operand:

{% highlight php %}

see('Title', Locator::combine('h1','h2','h3')); ?>

{% endhighlight %}

This will search for Title text in either h1, h2, or h3 tag. You can also combine CSS selector with XPath locator:

{% highlight php %}

fillField(Locator::combine('form input[type=text]','//form/textarea[2]'), 'qwerty'); ?>

{% endhighlight %}

As a result the Locator will produce a mixed XPath value that will be used in fillField action.

tabIndex

Do you often use the TAB key to navigate through the web page? How do your site respond to this navigation? You could try to match elements by their tab position using tabIndex method of Locator class.

{% highlight php %}

fillField(Locator::tabIndex(1), 'davert'); $I->fillField(Locator::tabIndex(2) , 'qwerty'); $I->click('Login'); ?>

{% endhighlight %}

href

Does the page contain link wo specified URL? Check that easily with href method of Locator class.

{% highlight php %}

see('Log In', Locator::href('/login.php')); ?>

{% endhighlight %}

And that's all folks for today. We are sure the locator class will evolve to simplify writing complex locators. If you have ideas what methods should be added, post them here. Or, which is better, patch this class and send Pull Request to Github.

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.