在阴影中查找元素 DOM
Finding elements in the shadow DOM
量角器 1.7.0 引入了一项新功能:新定位器 by.deepCss
which helps to find elements within a shadow DOM。
它涵盖了哪些用例?你想什么时候到达阴影中的元素 DOM?
我问这个问题的原因是我缺少这件事的动机部分——我认为量角器主要是一个有助于模拟真实用户交互的高级框架。访问影子树听起来像是一个非常深奥的技术问题,你为什么要这样做让我很困惑。
The reason I ask the question is that I'm missing on the motivational part of the matter - I thought about protractor mainly as a high-level framework that helps to mimic real user interactions. Accessing shadow trees sounds like a very deep down technical thing and why would you want to do it is confusing me.
在这个显示影子 DOM 介绍的 website 中似乎并非如此。它说:
Shadow DOM separates content from presentation thereby eliminating naming conflicts and improving code expression.
Shadow DOM 主要帮助分离内容以避免命名冲突和改进代码表达,使其更整洁更好(我假设)。很抱歉,我实际上并没有使用 Selenium,所以这里有一个包含更多信息的网站:http://webcomponents.org/polyfills/shadow-dom/
希望对您有所帮助!
为了回答您的问题,这里有一个相关问题:"what information does shadow dom provide that looking at raw html does not?"
以下代码片段创建了一个 shadom dom(通过 chrome 或 firefox 查看):
<input type="date">
如果您单击箭头,将打开一个包含所有日期的弹出窗口,您可以 select 它。
现在假设您正在构建一个酒店预订应用程序,并且您制作了一个自定义影子 dom 日期选择器,当房间不可用时,它会在其中隐藏(并且不允许用户 select)日期.
查看原始 html,您会看到 <input type="date">
,以及用户 select 编辑的 value/dates。但是,您将如何测试停电 UI 是否按预期工作?为此,您需要检查弹出窗口所在的阴影 dom。
量角器 1.7.0 引入了一项新功能:新定位器 by.deepCss
which helps to find elements within a shadow DOM。
它涵盖了哪些用例?你想什么时候到达阴影中的元素 DOM?
我问这个问题的原因是我缺少这件事的动机部分——我认为量角器主要是一个有助于模拟真实用户交互的高级框架。访问影子树听起来像是一个非常深奥的技术问题,你为什么要这样做让我很困惑。
The reason I ask the question is that I'm missing on the motivational part of the matter - I thought about protractor mainly as a high-level framework that helps to mimic real user interactions. Accessing shadow trees sounds like a very deep down technical thing and why would you want to do it is confusing me.
在这个显示影子 DOM 介绍的 website 中似乎并非如此。它说:
Shadow DOM separates content from presentation thereby eliminating naming conflicts and improving code expression.
Shadow DOM 主要帮助分离内容以避免命名冲突和改进代码表达,使其更整洁更好(我假设)。很抱歉,我实际上并没有使用 Selenium,所以这里有一个包含更多信息的网站:http://webcomponents.org/polyfills/shadow-dom/
希望对您有所帮助!
为了回答您的问题,这里有一个相关问题:"what information does shadow dom provide that looking at raw html does not?"
以下代码片段创建了一个 shadom dom(通过 chrome 或 firefox 查看):
<input type="date">
如果您单击箭头,将打开一个包含所有日期的弹出窗口,您可以 select 它。
现在假设您正在构建一个酒店预订应用程序,并且您制作了一个自定义影子 dom 日期选择器,当房间不可用时,它会在其中隐藏(并且不允许用户 select)日期.
查看原始 html,您会看到 <input type="date">
,以及用户 select 编辑的 value/dates。但是,您将如何测试停电 UI 是否按预期工作?为此,您需要检查弹出窗口所在的阴影 dom。