这是鼠标悬停的html代码。我希望能够使用javascript编写脚本,将鼠标悬停在“Product& Services”上,然后单击isentia.mediaportal
请帮忙,因为这是我的面试 感谢
09-30 10:06:25.105 2456-2456/com.troychuinard.fanpolls E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.troychuinard.fanpolls, PID: 2456
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.google.firebase.auth.FirebaseUser.getUid()' on a null object reference
at com.troychuinard.fanpolls.SignupActivity$5.onComplete(SignupActivity.java:280)
at com.google.android.gms.tasks.zzf.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
我创建了这个spec.js
<li class="first-item has-children dropdown products first">
<a href="#" class="dropdown-toggle root-menu">Products & Services</a>
<ul class="dropdown-menu">
<li class="first-item has-children dropdown all-products">
<a href="#" class="">Products</a>
<ul class="">
<li class="first-item has-children">
<a title="isentia.mediaportal" href="/tools/mediaportal" class="">isentia.mediaportal</a>
<ul class="">
<li class="first-item menu_blurb"><span>Our Suite of Media Monitoring Tools: All your PR & Analytics in one platform</span></li>
答案 0 :(得分:0)
您需要使用browser.actions()
对任何webelement执行鼠标操作。尝试以下代码。
var EC = protractor.ExpectedConditions;
var productsAndServiceMenu = element(by.linkText("Products & Services"));
var subMenu = element(by.linkText("isentia.mediaportal"));
browser.actions().mouseMove(productsAndServiceMenu).perform();
browser.wait(EC.visibilityOf(subMenu),5000);
subMenu.click();
参考http://www.protractortest.org/#/api?view=webdriver.WebDriver.prototype.actions