减慢节点中的硒 [英] Slowing down Selenium in Node

查看:69
本文介绍了减慢节点中的硒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用Node学习Selenium以使我的UI自动化.

I've just began learning Selenium with Node to automate my UI.

我有以下脚本(完美运行) 但是,我希望每个语句在较慢的时间(当前速度非常快)下依次执行. 我该怎么做呢?

I have the following script (which works perfectly) However, I am wanting the statements to each execute one after another at a slower time (at the moment it is super fast). How do I do this?

const By = selenium.By;
driver.findElement(By.xpath("/html/body/div/a[1]")).click();
const firstName = driver.findElement(By.id("firstName"));
firstName.sendKeys("Jon");
const lastName = driver.findElement(By.id("lastName"));
lastName.sendKeys("Smith");

推荐答案

简单地说,降低程序执行的速度 破坏了 Test的目的自动化. Test Automation 的主要目标是加快执行 Manual Validation 的重复任务.因此,试图减慢执行速度将无法达到 Test Automation 的主要目的.

In simple words slowing down the speed of the Program Execution defeats the purpose of Test Automation. The main objective of Test Automation is to speed up the execution of repetitive task of Manual Validation. Hence trying to slow down the speed of execution will defeat the main purpose of Test Automation.

话虽如此,值得一提的是,您必须面对某些情况,即必须将快速移动的 WebDriver 实例与滞后的 Web Client 实例同步.在这种情况下,您必须以waits >隐式等待显式等待,即 WebDriverWait

Having said that, it is worth to mention moving forward you have to face certain situation where you have to synchronize the fast moving WebDriver instance with the lagging Web Client instance. In those cases you have to induce waits in the form of Implicit Waits and Explicit Waits i.e. WebDriverWait pertaining to WebElementCondition

因此,在Node中降低Selenium 会违反所有最佳做法,因此必须避免.

Hence Slowing down Selenium in Node would be against all best practices and must be avoided.

这篇关于减慢节点中的硒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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