Make WebDriver::getLocator (and WebDriver::getStrictLocator) public
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- php
- Lĩnh vực
- testing-qa
Hướng nghiên cứu
Bắt đầu từ các điểm truy cập WebDriver::getLocator và WebDriver::getStrictLocator, rồi kiểm tra cách các hàm public như WebDriver::findElements nhận các đối số WebDriverBy. Xác minh rằng module nhận được thông qua $this->getModule('WebDriver') có thể sử dụng cả hai dịch vụ định vị từ một custom action, đồng thời xác nhận rằng việc xử lý selector không hợp lệ vẫn được bao phủ bởi hành vi hiện có được thể hiện trong issue.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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!
- Ngôn ngữ chính
- PHP
- Star
- 39
- Fork
- 25
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Codeception/module-webdriver
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Codeception/module-webdriver#151 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
Codeception/module-webdriver#135 ·
-
Example of `executeAsyncJs()` Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 38/100
Codeception/module-webdriver#130 ·
-
Bug: `MalformedLocatorException` thrown for `id`s that don't start with a character (HTML 5) Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
Codeception/module-webdriver#128 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
Codeception/module-webdriver#126 ·
Tất cả issue của Codeception/module-webdriver
Issue tương tự
-
Admissions heading updates Đang mởa11y admissions.uiowa.edu needs grooming SiteImprove best practice
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Save States Menu Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Error on exporting the error log Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
pluginsGLPI/datainjection#673 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
octobercms/october#6130 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
getgrav/grav-plugin-form#656 ·