JavaScript是否与严格的页面对象模式兼容?

编程入门 行业动态 更新时间:2024-10-26 13:27:52
本文介绍了JavaScript是否与严格的页面对象模式兼容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用Page Object Pattern with Java构建了各种Test Automation框架( code.google。 com / p / selenium / wiki / PageObjects )。

I have built various Test Automation frameworks using the Page Object Pattern with Java (code.google/p/selenium/wiki/PageObjects).

我发现的两大好处是:

1)当你有一个页面实例时,你可以看到可用的方法(例如输入主页。将显示你可以从主页调用的所有动作/方法)

1) You can see what methods are available when you have an instance of a page (e.g. typing homepage. will show me all the actions/methods you can call from the homepage)

2)因为导航方法(例如goToHomepage())返回后续页面的实例(例如主页),所以只需编写代码并查看它所在的位置即可浏览测试。

2) Because navigation methods (e.g. goToHomepage()) return an instance of the subsequent page (e.g. homepage), you can navigate through your tests simply by writing the code and seeing where it takes you.

例如

WelcomePage welcomePage = loginPage.loginWithValidUser(validUser); PaymentsPage paymentsPage = welcomePage.goToPaymentsPage();

这些好处与Java完美配合,因为对象的类型(或本例中的页面)是已知的IDE。

These benefits work perfectly with Java since the type of object (or page in this case) is known by the IDE.

但是,使用JavaScript(动态类型语言),对象类型在任何时候都不固定,并且通常与IDE不明确。因此,我无法看到如何在使用JavaScript构建的自动化套件中实现这些优势(例如,使用Cucumber)。

However, with JavaScript (dynamically typed language), the object type is not fixed at any point and is often ambiguous to the IDE. Therefore, I cannot see how you can realise these benefits on an automation suite built using JavaScript (e.g. by using Cucumber).

任何人都可以告诉我如何使用JavaScript页面对象模式可以获得这些好处吗?

Can anyone show me how you would use JavaScript with the Page Object Pattern to gain these benefits?

推荐答案

我对这种模式并不多。但我会提供一些细节,也许它对你有所帮助。 http: //www.guru99/page-object-model-pom-page-factory-in-selenium-ultimate-guide.html

I am not much about this patterns.but i will give some details maybe it helps to you. www.guru99/page-object-model-pom-page-factory-in-selenium-ultimate-guide.html

www.assertselenium/automation-design-practices/page -object-pattern /

实现此目的的一个好方法是使用 TypeScript (这是 JavaScript 的静态类型版本:

It seems a great way to achieve this is to use TypeScript (which is a statically typed version of JavaScript):

en.wikipedia/wiki/TypeScript

更多推荐

JavaScript是否与严格的页面对象模式兼容?

本文发布于:2023-05-31 22:06:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/400259.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对象   模式   页面   JavaScript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!