首页 > 解决方案 > 使用 selenium webdriver 自动化网站登录过程

问题描述

我尝试使用 selenium webdriver 和 excel VBA 登录网站,但我卡在登录页面

我使用以下代码:

Dim bot As New WebDriver

bot.Start "chrome", "myurl"
bot.Get "/"

'select from drop down
bot.FindElementById("MainContent_ddlRoleType").AsSelect.SelectByValue "7"

bot.FindElementById("MainContent_UserName").SendKeys "userid"
bot.FindElementById("MainContent_Password").SendKeys "password"

'select from drop down
bot.FindElementById("MainContent_ddlAuxCentre").AsSelect.SelectByValue "1"

bot.FindElementById("MainContent_LogOnButton").SendKeys bot.Keys.Enter

正确输入所有数据,直到单击登录按钮,这会产生以下错误消息:

此请求的 URL 长度超过了配置的 maxUrlLength 值。

说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

异常详细信息:System.Web.HttpException:此请求的 URL 长度超过了配置的 maxUrlLength 值。

源错误:

在执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常起源和位置的信息。

堆栈跟踪:

[HttpException (0x80004005): The length of the URL for this request exceeds the configured maxUrlLength value.]
   System.Web.HttpRequest.ValidateInputIfRequiredByConfig() +11320030
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +371

标签: excelvbaseleniumselenium-webdriver

解决方案


It was a server side error a shortened url lead me to the same page so the problem was fixed. Thanks. –</p>


推荐阅读