如何使用Selenium跳过之前的页面直到最后一页。

huangapple go评论76阅读模式
英文:

How to bypass previous pages to the last using Selenium

问题

我有这样的情景,有5个具有相同URL的页面,每个页面都有输入HTML元素。假设URL是 https://abcnyweb.com/pages。导航的问题在于所有页面共享这一个唯一的URL,因此如果我想直接跳转到第五页而不经过第一页,是不可能的。我必须从第一个页面开始重新填写表单。

每个页面都有从上一页导航到下一页的按钮,在每个页面中有15个以上的要填写的元素。如果我不填写这些输入,验证将不允许我进入下一个页面。

有没有办法可以在不必通过前面的4页点击的情况下,直接跳转到第五页?

无头Selenium脚本能帮助实现这一点吗?

每个页面上的表单在我点击提交按钮时都会保存。

英文:

I have this scenario, there are 5 pages with the same URL, each with inputs HTML elements. Let's say the URL is https://abcnyweb.com/pages. The problem with navigation is that all the pages shared this one and only URL, so if I want to move to the fifth page without landing on the first page, it's not possible. I have to start filling the forms all over again from the first one.

There are buttons that leads from the previous to the next page, and there are more than 15 elements in each page to be filled. If I don't fill the inputs the validation wouldn't allow move to the next page.

Is there a way I can move to the fifth page without having to click through the 4s before it?

World headless Selenium script help to achieve this?

The form on each page saves when I click the submit button.

答案1

得分: 1

这取决于您的应用程序中导航是如何实现的。

如果是客户端渲染(由 JavaScript 处理),您可以调用适当的 JavaScript 函数

如果是服务器端渲染(通过 HTTP 检索),请检查请求的参数。如果其中一些参数代表页码,请使用正确的参数调用请求。如果不是这种情况,恐怕您将没有任何替代方法。

英文:

It depends on how the navigation is implemented on your application.

If it's client-side rendered (handled by javascript), you can call the appropriated js function.

If it's server-side rendered (retrieved with HTTP), check the parameters of the request. If some of them stand for the page number, call the request with the good parameters. If it's not the case, i'm afraid you won't have any alternative.

huangapple
  • 本文由 发表于 2020年8月28日 22:22:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/63635668.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定