量角器中的鼠标操作无法正常工作 [英] Mouse actions not working correctly in protractor

查看:97
本文介绍了量角器中的鼠标操作无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试上传图片。但是当我上传时,图像的某些部分可能会被剪切。因此我们可以选择裁剪该图像。所以我拖动图像的两侧并单击上传按钮。因此在单击上传按钮后,它成功上传了当我通过自动化脚本执行所有这些操作时,图像似乎并未完全上传,仍然看起来像被剪切。

I am trying to upload a image. But when i am uploading, some portion of the image may get cut.So we have an option to crop that image.So i drag both side of the image and click on the upload button.So after click on upload button, it successfully uploading full portion of the image while doing it manually.When i am doing all these actions via automation script, the image is not seems to be uploaded fully,still it appears like get cut.

这种裁剪是在iframe中完成的。下面使用我所使用的代码,并附上图片的屏幕快照和html代码。

This cropping is done in a iframe.The code i have used is given below and attaching the screen shot of the image and the html code.

browser.switchTo().frame(element(by.css(".a-va")).getWebElement()).then (function(){
  var element1= element(by.css('.Nf-ko'));
  var element2= element(by.css('.Nf-ko:nth-child(3)'));
  browser.actions().dragAndDrop(element1,{x:0,y: -100}).mouseUp().perform();
  browser.actions().dragAndDrop(element2,{x:0,y: 100}).mouseUp().perform();
  element(by.css("[role='button']")).click();
});

我也尝试过

browser.switchTo().frame(element(by.css(".a-va")).getWebElement()).then (function(){
  var element1= element(by.css('.Nf-ko'));
  var element2= element(by.css('.Nf-ko:nth-child(3)'));
  browser.actions().mouseDown(element1).mouseMove({x:0,y: -100}).mouseUp().mouseDown(element2).mouseMove({x:0,y: 100}).mouseUp().perform();
 element(by.css("[role='button']")).click(); 
});

通过使用以上代码,我可以在浏览器中看到执行了拖动操作。单击上传按钮,而不是裁剪图像,而是显示未裁剪的图像。我不明白这里的错误操作。有人可以帮我吗。谢谢您

By using above code, i can see in the browser, that the dragging action is performed.But after clicking upload button,instead of cropped image it shows the uncropped one itself.I am not understanding what is the wrong action here.Can anyone help me.Thanks in Advance

推荐答案

当我更改了上载按钮的定位器时,它工作得很好。

When i changed the locator of upload button, it worked perfectly.

 browser.switchTo().frame(element(by.css(".a-va")).getWebElement()).then (function(){
   var element1= element(by.css('.Nf-ko'));
   var element2= element(by.css('.Nf-ko:nth-child(3)'));
   browser.actions().dragAndDrop(element1,{x:0,y: -100}).mouseUp().perform();
   browser.actions().dragAndDrop(element2,{x:0,y: 100}).mouseUp().perform();
   element(by.css(".Nf-tb-Qk-mk")).click();
 });

这篇关于量角器中的鼠标操作无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆