gpt4 book ai didi

java - 执行 Angular ng-if 条件后,Selenium DOM 没有改变

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:01:36 25 4
gpt4 key购买 nike

我们在具有角度 ng-if 条件的页面上有以下代码。

<p ng-if="!old_email" style="line-height: 20px; font-weight: normal;"><b>Hi,</b><br><br>
We have created a new account with &rsquo;{{ new_email }}&lsquo;, for you on<br> Plobal Apps to preview and test your app and mailed you the details. Please check your inbox.
</p>

<p ng-if="new_user && old_email" style="line-height: 20px; font-weight: normal;"><b>Hi,</b><br><br>
We have created a new account with &rsquo;{{ new_email }}&lsquo;, for you on<br> Plobal Apps to preview and test your shopify app and mailed you the details. Please check your inbox.
<br />
You have been logged out of the previous account with &rsquo;{{ old_email }}&lsquo;.
</p>

<p ng-if="existing_user && old_email" style="line-height: 20px; font-weight: normal;"><b>Hi,</b><br><br>
We have logged you in with &rsquo;{{ new_email }}&lsquo;, on Plobal Apps to preview and test your shopify app.
<br />
You have been logged out of the previous account with &rsquo;{{ old_email }}&lsquo;.
</p>

ng-if 条件将根据要求动态执行和拾取标签。我在 html 页面上观察到一切正常。检查页面后,我观察到以下 html 代码。

<!-- ngIf: !old_email -->

<!-- ngIf: new_user && old_email -->

<!-- ngIf: existing_user && old_email --><p class="ng-binding ng-scope" ng-if="existing_user &amp;&amp; old_email" style="line-height: 20px; font-weight: normal;"><b>Hi,</b><br><br>
We have logged you in with ’suwarnawandhekar46@gmail.com‘, on Plobal Apps to preview and test your shopify app.
<br>
You have been logged out of the previous account with ’test@plobalapps.com‘.
</p><!-- end ngIf: existing_user && old_email -->

如果我用 selenium 打印父元素的 innerHTML 然后我发现

<p ng-if="!old_email" style="line-height: 20px; font-weight: normal;"><b>Hi,</b><br><br>
We have created a new account with ’{{ new_email }}‘, for you on<br> Plobal Apps to preview and test your app and mailed you the details. Please check your inbox.
</p>

<p ng-if="new_user &amp;&amp; old_email" style="line-height: 20px; font-weight: normal;"><b>Hi,</b><br><br>
We have created a new account with ’{{ new_email }}‘, for you on<br> Plobal Apps to preview and test your shopify app and mailed you the details. Please check your inbox.
<br>
You have been logged out of the previous account with ’{{ old_email }}‘.
</p>

<p ng-if="existing_user &amp;&amp; old_email" style="line-height: 20px; font-weight: normal;"><b>Hi,</b><br><br>
We have logged you in with ’{{ new_email }}‘, on Plobal Apps to preview and test your shopify app.
<br>
You have been logged out of the previous account with ’{{ old_email }}‘.
</p>

根据我的理解,Selenium DOM 在 Angular ng-if 条件执行后没有改变。如果有人知道如何告诉 selenium 执行角度 ng-if 条件然后查找元素,请帮助我。

最佳答案

请重新检查以下代码是否真的存在:

ng-if="new_user &amp;&amp; old_email"

因为最初它是:

ng-if="new_user && old_email"

即看起来 Selenium 将 && 符号替换为

&amp;&amp;

ng-if 中,这是问题的根源:Angular 无法解析“非 JS”代码(或错误地解释它)

附言以下代码也是如此:

ng-if="existing_user &amp;&amp; old_email"

&amp;&amp;

也在 ng-if 中代替 && 出现。

关于java - 执行 Angular ng-if 条件后,Selenium DOM 没有改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36721459/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com