首先来看selenium.click()的文档说明:
Clicks on a link, button, checkbox or radio button. If the click action causes a new page to load (like a link usually does), call waitForPageToLoad.
可见,对于checkbox,除了可以用selenium.check()外,还能用selenium.click().但是,当面对带有javascript方法的checkbox,最好是用click(),这样的checkbox源代码如下:
<input type="checkbox" id="configurationForm:hraZipFile" name="configurationForm:hraZipFile" checked="checked" onclick="A4J.AJAX.Submit('_viewRoot','configurationForm',event,{'oncomplete':function(request,event,data){removeHraCheck()},'similarityGroupingId':'configurationForm:j_id82','parameters':{'configurationForm:j_id82':'configurationForm:j_id82'} ,'eventsQueue':'config','actionUrl':'/aces/packaging/packageConfiguration.seam'} )">
当我们直接用check()方法的时候,onclick()方法是不能被调用到的,如果用click()方法,onclick()方法就能被执行.再来看实际的例子:
图片中右边的checkbox是靠左边的checkbox触发的,原来我选中这两个checkbox的代码是这样的:
selenium.check(PackageConsts.CLAIM_ZIP_CBOX);
selenium.check(PackageConsts.CLAIM_PASSWRD_CBOX);
在保存页面之后,再回来,发现实际上右边的checkbox没有被选中,而且程序也没有报错.
后来再把check改成click,右边的checkbox就能选中了.代码如下,主要click后需要等待:
selenium.click(PackageConsts.CLAIM_ZIP_CBOX);
pause(10000)
selenium.click(PackageConsts.CLAIM_PASSWRD_CBOX);
- 大小: 3.7 KB
分享到:
相关推荐
Selenium.WebDriver.4.0.0-alpha02.nupkg,Selenium.WebDriver 4.0,Selenium is a set of different software tools each with a different approach to supporting browser automation. These tools are highly ...
Selenium.RC.2.24.0.nupkg
Selenium.Support.4.0.0-alpha02.nupkg, C#, 上传 Selenium 4.0
Over 90 recipes to help you build and run automated tests for your web applications with Selenium WebDriver About This Book Learn to leverage the power of Selenium WebDriver with simple examples that...
selenium.py selenium.py
Selenium.WebDriver.3.141.0该版本是最新稳定版的,之前帮同事下过,然后自己电脑nuget安装的时候总是报错,没办法,只好拷过来了
Selenium 客户端和 WebDriver 语言绑定(Selenium Clients and WebDriver ...为了创建与 Selenium Server (Remote WebDriver) 交互的脚本或创建本地 Selenium WebDriver 脚本,您需要使用特定于语言的客户端驱动程序。
selenium支持的IE驱动
Selenium
selenium.click("btnG"); System.out.println("begin search"); selenium.waitForPageToLoad("30000"); assertTrue(selenium.isTextPresent("s")); System.out.println("finsh assert"); } } step5:...
HelloSelenium.java
selenium.webdriver.4.8.2.nupkg
selenium.jar selenium资源包
Packtpub.Selenium.1.0.Testing.Tools.Beginners.Guide.Nov.2010.rar
( selenium.rc.2.42
selenium3.141.59版本,用来在java平台学习浏览器自动化,需要配合浏览器驱动一起使用,3.141.59版本需要火狐驱动0.26,其他浏览器没用过,可以自己查一下。
Packtpub.Selenium.2.Testing.Tools.Beginners.Guide.Oct.2012.pdf
Selenium.with.Python.A.Beginners.Guide.2019,自动化测试
Selenium自动录制脚本,java版本;所需要的jar包。包含(Selenium-client.jar,selenium-server.jar;junit.jar)
selenium-3.141.0.tar.gz