Codeception / Codeception/module-webdriver

Suggestion: `seeElementHasClass()`

未關閉
#126 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
PHP
星號
39
分支
25
PR 合併指標
30 天內沒有已合併 PR

描述

I wrote a simple method for `App\Tests\Support\Helper\Acceptance` to check if an HTML element has a certain CSS class. Does the same as JavaScript `.classList.contains()`:

```php
public function seeElementHasClass(array|string $element, string $class): void
{
$I = $this->getModule('WebDriver');
$classesString = $I->grabAttributeFrom($element, 'class');
$classesArray = explode(' ', $classesString);
$this->assertContains($class, $classesArray);
}

public function dontSeeElementHasClass(array|string $element, string $class): void
{
$I = $this->getModule('WebDriver');
$classesString = $I->grabAttributeFrom($element, 'class');
$classesArray = explode(' ', $classesString);
$this->assertNotContains($class, $classesArray);
}
```

Maybe somebody could add it to the module? :-)

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。