我是WebPagetest (https://www.webpagetest.org/)的新手,在登录表单上遇到了一些问题。我正在使用脚本,可以使用表单导航到页面,但似乎没有正确地输入任何表单值,表单也没有提交。
下面是我的脚本的一个版本:
logData 1
navigate https://www.example.com/secure/login
setValue name=username activation_test
setValue name=password password
submitForm id=signInForm
//clickAndWait id=signInBtn
//exec document.getElementsByTagName('html')[0].style.display = 'none';
sleep 5
block google.com/csi
navigate https://www.example.com/?jbhp=true当然,我的第一个想法是确保我的HTML元素匹配,但是它们看起来很好……
输入tabindex="1“aria-required=”id=“用户名”maxlength="64“maxlength=placeholder=”电子邮件地址或用户名“type=”文本“value=”
输入tabindex="2“aria-required=”id=“class=成功需要”id=“密码”id=placeholder=“密码”type=“密码”value=“
表单action="#“action=method=”发布“class=”表单formLarge“”novalidate=“
按钮tabindex="3“tabindex= class="ancBtn lrg”数据跟踪-单击=“登录:在”type=“提交”
测试的结果页显示它导航到最终位置,好像没有登录。另外,我认为这是结果的一部分:Step_2 (错误:导航错误)。可悲的是,如果有更好的文档说明是什么导致了导航错误,我还没有找到它。
最后,如果我从使用"submitForm“切换到"clickAndWait”(在上面的示例中被注释掉),结果唯一的区别是Step_2显示的是页面的屏幕截图,而不仅仅是橙色块。
发布于 2019-02-25 21:02:11
IFrames。 IFrames.如果你找到了我的问题,上面,我敢打赌你的网页有IFrames。在我的例子中,我的IFrame来自与浏览器页面相同的域--如果您的IFrame不是这样的话,我不确定这是否有效。
要访问IFrame中的元素,我必须忘记"setValue“、"clickAndWait”等等。我必须直接去看Javascript。脚本中,它看起来有点像下面的例子:
exec document.querySelector("iframe[id=stupidIFrameId]").contentDocument.querySelector("input[id=password]").value = 'password'
execAndWait document.querySelector("iframe[id=stupidIFrameId]").contentDocument.querySelector("button[id=signInButton]").click()https://stackoverflow.com/questions/54832708
复制相似问题