Java Script 学习笔记 (二) Casper JS

1. click() VS mouse.click()

    在写自动化脚本要勾选一个复选框时,用casper.mouse.click() 无法选上这个checkbox, 需要用到casper.click()才可以。但是同事那里用哪种写法都可以, 我们同样都是在test子命令下执行的脚本。

1     casper.then(function(){
2         this.mouse.click("#root > div > form > div:nth-child(8) > div > div > label > span.ant-checkbox > input");
3     });
4     casper.then(function(){
5         this.capture("test-demo0.2-"+(captureIdx++)+"-wrongreg2.png");
6     });
View Code

  上面这段脚本得到的截图:
  

 

  

1     casper.then(function Initial(){
2         this.click("#root > div > form > div:nth-child(8) > div > div > label > span.ant-checkbox > input");
3     });
4 
5     casper.then(function Cap(){
6         this.capture("test-demo0.2-"+(captureIdx++)+"-wrongreg2.png");
7     });
View Code

上面这段脚本得到的截图:

原文地址:https://www.cnblogs.com/cheese320/p/8067782.html