Make WebDriver::getLocator (and WebDriver::getStrictLocator) public
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 45/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- php
- Ambito
- testing-qa
Direzione di ricerca
Inizia dai punti di ingresso WebDriver::getLocator e WebDriver::getStrictLocator e verifica come le funzioni pubbliche come WebDriver::findElements ricevono gli argomenti WebDriverBy. Verifica che il modulo ottenuto tramite $this->getModule('WebDriver') possa usare entrambi i servizi di localizzazione da un'azione personalizzata e conferma che la gestione dei selettori non validi rimanga coperta dal comportamento esistente mostrato nell'issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What are you trying to achieve?
Write a custom action that uses the WebDriver locator service to locate an element by its selector string.
I would like to do this by getting the web driver module with $this->getModule('WebDriver') rather than extending WebDriver to keep my testing architecture consistent with other modules I've written.
What do you get instead?
Unable to use the functions because they're protected.
/**
* @param $selector
* @return WebDriverBy
* @throws \InvalidArgumentException
*/
protected function getLocator($selector)
{
if ($selector instanceof WebDriverBy) {
return $selector;
}
if (is_array($selector)) {
return $this->getStrictLocator($selector);
}
if (Locator::isID($selector)) {
return WebDriverBy::id(substr($selector, 1));
}
if (Locator::isCSS($selector)) {
return WebDriverBy::cssSelector($selector);
}
if (Locator::isXPath($selector)) {
return WebDriverBy::xpath($selector);
}
throw new \InvalidArgumentException("Only CSS or XPath allowed");
}
// ...and
/**
* @param array $by
* @return WebDriverBy
*/
protected function getStrictLocator(array $by)
{
$type = key($by);
$locator = $by[$type];
switch ($type) {
case 'id':
return WebDriverBy::id($locator);
case 'name':
return WebDriverBy::name($locator);
case 'css':
return WebDriverBy::cssSelector($locator);
case 'xpath':
return WebDriverBy::xpath($locator);
case 'link':
return WebDriverBy::linkText($locator);
case 'class':
return WebDriverBy::className($locator);
default:
throw new MalformedLocatorException(
"$by => $locator",
"Strict locator can be either xpath, css, id, link, class, name: "
);
}
}
Details
It seems to me that these are services that the WebDriver module should expose, as some public WebDriver functions take WebDriverBy arguments (e.g. WebDriver::findElements). We need some service to get these WebDriverBy arguments, or we won't be able to use the public function calls that are exposed through $this->getModule('WebDriver');. Alternatively, maybe the WebDriver module should expose some public findElement type of function that takes a selector string rather than a WebDriverBy instance.
- Codeception version: 2.2.10
- PHP Version: 7.0.10
Apologies if this has already been discussed, I didn't see it on the issues board. And thanks for making such a fantastic tool!
- Lingua principale
- PHP
- Stelle
- 39
- Fork
- 25
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Codeception/module-webdriver
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
Codeception/module-webdriver#151 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
Codeception/module-webdriver#135 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 38/100
Codeception/module-webdriver#130 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
Codeception/module-webdriver#128 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
Codeception/module-webdriver#126 ·
Tutte le issue di Codeception/module-webdriver
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
pluginsGLPI/datainjection#673 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
octobercms/october#6130 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
getgrav/grav-plugin-form#656 ·
-
customer-support needs-triage Platform(Default)
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
sync-en
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100