[Protractor] Protractor Interactive with elementor

本文介绍如何使用Protractor测试Angular页面,包括安装依赖、启动浏览器驱动、定位页面元素、触发搜索功能及清理输入等操作,同时提供使用WebStorm插件辅助测试的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Install:

npm install -g elementor

 

Then run:

webdriver-manager start

 

Lets say if we want to test 'http://angular.github.io/protractor/#/api' page:

elementor http://angular.github.io/protractor/#/api

 

Notice: close the chrome debug tool first! Otherwise protractor cannot run!

 

  • When the page open, right click the tab, choose duplicate!
  • Choose the second tab, open the chrome debugger tool
  • In debugger tool, in elements tab, inspet one element, see the protractor tab:

The number "1" you see here indicate that there is only 1 element match hte locators. 

 

 

Let's select:

by.css("#searchInput")

 

  • Go to the first window, click the extension tool:

  • Type what you want in the search input:

Then you can find the element you want.

 

  • You can use 'sendKeys()' function to trigger seach:
element.all(by.css("#searchInput")).sendKeys("filter")

 

  • You can use 'clear()' function to clean the input:
element.all(by.css("#searchInput")).clear()

 

---------------------------------

 

You can also use webstorm plugin for testing. Install the 'elementor' plugin.

When imaging you are doing some unit testing.

 

You can select the code you want, right click, in the pop menu select 'Test selected locator'.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值