Question

J'ai du code HTML qui ressemble à ceci:

<h1 id="header">Header</h1>

Je voudrais cliquer à l'aide Watir et XPath.

Était-ce utile?

La solution 3

browser.h1(:xpath, "//h1[@id='header']").click

Autres conseils

Après-watir WebDriver 0.5.1 sélection aléatoire avec un élément XPath a été mis à jour:

browser.element(:xpath => "//h1[@id='header']").click

grâce à: https://groups.google.com/forum/#!topic/ watir général / c6Orvy7Qalw

En outre pas XPath, mais fonctionne:

browser.h1(:html, /header/).click

Ne pas utiliser XPath, mais il fonctionne:

browser.h1(:id, "header").click

Un autre exemple en utilisant XPath ici:

browser.element xpath: "//div/cite[contains(.,'some text')]/ancestor::div[@class='rc']/h3/a"

Commander ce cadre simple que je téléchargé à Github: https://github.com/atfuentess/watir_cucumber_automation/

La pile utilisée est la suivante: watir / concombre / rspec

Peut-être qu'il peut aider quelqu'un.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top