问题描述
我们有一个客户要求在 Power 应用中实现测试自动化。 Power Apps 有自己的测试框架,但仍处于实验模式,不建议用于生产环境。
我有使用 Selenium 的经验,但在为 Power Apps 定位 Web 元素时遇到问题。 我正在尝试找到一个文本框并输入任何值,即使网络元素是独一无二的,但 selenium 无法找到这些元素。
HTML
<div class="canvasContentDiv appmagic-control-view appmagic-content-
control-name _vst_" data-control-id="17" data-control-name="TextInput1"
style="width: 419px; height: 60px; z-index: 17; position: absolute; top:
517px; left: 105px;"><div class="appmagic-borderfill-container"
style="background-color: rgb(186,202,226); border-style: solid; border-
width: 2px; border-color: rgb(0,18,107); border-radius: 5px; margin:
-1px;"><div class="appmagic-border-inner" style="margin: -1px;"><div
class="react-knockout-control" spellcheck="false" style="position:
absolute; inset: 0px;">
<div class="appmagic-textBox" touch-action="pan-x pan-y" appmagic-
control="TextInput1">
<!-- ko if: (mode() === "multiline") --><!-- /ko -->
<!-- ko if: (mode() !== "multiline") -->
<input appmagic-control="TextInput1textBox" class="appmagic-text mousetrap
block-undo-redo" maxlength="10000" data-bind="
attr: {
type: mode() === 'password' ? 'password' : 'text',title: properties.Tooltip() || null,'aria-label': properties.AccessibleLabel() || null,placeholder: properties.HintText,readonly: viewState.displayMode() ===
AppMagic.Constants.displayMode.View,contenteditable: viewState.displayMode() ===
AppMagic.Constants.displayMode.Edit,'data-control-part': properties.Clear() ? 'text clearable' : 'text',inputmode: keyboardMode
},css: {
underline: properties.Underline,strikethrough: properties.Strikethrough,readonly: viewState.displayMode() ===
AppMagic.Constants.displayMode.View
},value: text,event: {
click: handleClick,change: handleOnChange
},style: {
fontFamily: properties.Font,fontSize: properties.Size,color: autoproperties.Color,fontWeight: properties.FontWeight,fontStyle: properties.Italic,textAlign: properties.Align,lineHeight: properties.LineHeight,paddingTop: properties.PaddingTop,paddingRight: properties.PaddingRight,paddingBottom: properties.PaddingBottom,paddingLeft: properties.PaddingLeft
},disable: viewState.displayMode() ===
AppMagic.Constants.displayMode.disabled" type="text" placeholder="Team
name..." contenteditable="true" data-control-part="text" inputmode="text"
tabindex="15" style="font-family: "Open Sans",sans-serif; font-
size: 21pt; color: rgb(0,0); font-weight: normal; font-style: normal;
text-align: left; line-height: 1.2; padding: 5px 5px 5px 12px;">
<div class="appmagic-text-clear-container">
<button class="appmagic-text-clear-button" data-control-part="clear" data-
bind="
visible: isFocused() && properties.Clear() &&
properties.Text() && mode() !== 'password' &&
viewState.displayMode() === AppMagic.Constants.displayMode.Edit,event: {click: handleClearClick},attr: {'aria-label': AppMagic.Strings.TextInputClearButtonLabel}" aria-
label="Clear value" tabindex="16" style="display: none;">
<svg class="appmagic-text-clear-svg" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 12 12" aria-hidden="true" focusable="false">
<polygon points="12,1.1 10.9,0 6,4.9 1.1,0 0,1.1 4.9,6 0,10.9 1.1,12
6,7.1 10.9,12 12,10.9 7.1,6" data-bind="style: {fill:
autoproperties.Color}" style="fill: rgb(0,0);"></polygon>
</svg>
</button>
</div>
<!-- /ko -->
</div>
</div></div></div></div>
尝试在下面找到网络元素-
driver.findElement(By.xpath("//div[@class='appmagic-textBox']")).sendKeys("test");
driver.findElement(By.xpath("//input[@class='appmagic-text mousetrap block-undo-redo']")).sendKeys("Test");
以下是Selenium返回的错误-
提前致谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)