首页 > 解决方案 > 如何验证shadow dom中的文本颜色?

问题描述

控制台中的 dom我正在尝试验证 shadow dom 中元素的文本颜色。

expect(browser.executeScript("return window.getComputedStyle(document.querySelector(\"body > moo-shell > auto-app\").shadowRoot.querySelector(\"section > auto-config\").shadowRoot.querySelector(\"section:nth-child(2) > div > div:nth-child(1) > section:nth-child(2) > div > vaadin-format-number-field\").shadowRoot.querySelector(\"#vaadin-format-number-field-label-1\"),':after').getPropertyValue('color')")).equals('rgb(204, 0, 0)');

F[09:37:59] E/launcher - javascript error: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.

标签: javascripthtmlseleniumprotractorshadow-dom

解决方案


推荐阅读