关闭并重新打开浏览器后,无法识别登录按钮 [英] Login button isn't recognised after closing and reopening the browser

查看:112
本文介绍了关闭并重新打开浏览器后,无法识别登录按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题,在测试用例中我正在自动化我需要关闭并重新打开浏览器。以下是我应采取的步骤

I have a strange issue ,in the test case I'm automating I'm required to close and reopen the browser. Here are the steps I should take

1)打开浏览器

2)点击登录按钮

3 )关闭并重新打开浏览器

3)Close and reopen browser

4)单击"登录"按钮

4)Click Login button

此时无法识别"登录"按钮,我尝试使用Palyback.wait我已经注意到浏览器本身无法识别并尝试使用searchproperties和Find方法查找浏览器,在添加代码
后,现在找到了浏览器但我的登录按钮仍然无法识别。这是我搜索登录按钮的代码

At this point the Login button isn't recognised, I have tried using Palyback.wait, waitforcontrol exist etc.I have noticed the browser itself isn't recognised and tried using the searchproperties and Find method to find the browser, after adding the code the browser is now found but my loginbutton still isn't recognised.Here is my code to search for the login button

  HtmlButton LoginButton = new HtmlButton(PageContent);

 HtmlButton LoginButton = new HtmlButton(PageContent);

LoginButton.SearchProperties [HtmlButton.PropertyNames .Id] = null;

LoginButton.SearchProperties[HtmlButton.PropertyNames.Id] = null;

LoginButton.SearchProperties [HtmlButton.PropertyNames.Name] = null;

LoginButton.SearchProperties[HtmlButton.PropertyNames.Name] = null;

LoginButton.SearchProperties [HtmlButton.PropertyNames.DisplayText ] ="登录" ;; 

LoginButton.SearchProperties[HtmlButton.PropertyNames.DisplayText] = "Login"; 

LoginButton.FilterProperties [HtmlButton.PropertyNames.Type] =" submit";

LoginButton.FilterProperties[HtmlButton.PropertyNames.Type] = "submit";

LoginButton.Find();

LoginButton.Find();

if(LoginButton.Exists)

if (LoginButton.Exists)

{

MessageBox.Show( "按钮存在");

MessageBox.Show("Button exists");

}

Mouse.Click(LoginButton,new Point(49,28));

Mouse.Click(LoginButton, new Point(49, 28));



此时我收到错误消息,指出没有任何具有指定属性的控件。


At this point I get an error saying there isn't any control with the specified properties.

如果我使用

  HtmlButton LoginButton = new HtmlButton();而不是

 HtmlButton LoginButton = new HtmlButton(); instead of

HtmlButton LoginButton = new HtmlButton(PageContent);

HtmlButton LoginButton = new HtmlButton(PageContent);

 

 

如有任何帮助,我们将不胜感激。

Any help would be appreciated.

 

 

推荐答案

尝试在单击按钮loginbutton.SearchConfigurations.Add(SearchConfiguration .AlwaysSearch);
try to add this line before clicking on the button loginbutton.SearchConfigurations.Add( SearchConfiguration .AlwaysSearch);


这篇关于关闭并重新打开浏览器后,无法识别登录按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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