失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > selenium java 验证码_如何使用Selenium WebDriver和Java从图像(验证码)中读取文本

selenium java 验证码_如何使用Selenium WebDriver和Java从图像(验证码)中读取文本

时间:2022-08-22 03:02:03

相关推荐

selenium java 验证码_如何使用Selenium WebDriver和Java从图像(验证码)中读取文本

我有注册网页,但在最后验证码显示..

我无法从图像中读取文本.我要提一下代码和输出..

@Test

public void loginTest() throws InterruptedException {

System.out.println("Testing");

driver.get("https://customer.onlinelic.in/ForgotPwd.htm");

WebElement element = driver.findElement(By.xpath("//*[@id='forgotPassword']/table/tbody/tr[5]/td[3]/img"));

System.out.println(" get the instance ");

String elementTest = element.getAttribute("src");

System.out.println("Element : " + elementTest);

}

输出:错误

Exception in thread “main” org.openqa.selenium.NoSuchElementException:

Unable to locate element:

{“method”:”xpath”,”selector”:”//[@id=’forgotPassword’]/table/tbody/tr[5]/td[3]/img”}

Command duration or timeout: 60.02 seconds For documentation on this error, please visit:

07000 Build info:

version: ‘2.35.0’, revision: ‘8df0c6b’, time: ‘-08-12 15:43:19’

System info: os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version:

‘6.1’, java.version: ‘1.6.0_26’ Session ID:

5f5b2e1a-56a4-49ad-8fd3-2870747a7768 Driver info:

org.openqa.selenium.firefox.FirefoxDriver Capabilities [{platform=XP,

acceptSslCerts=true, javascriptEnabled=true, browserName=firefox,

rotatable=false, locationContextEnabled=true, version=23.0.1,

cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true,

browserConnectionEnabled=true, nativeEvents=true,

webStorageEnabled=true, applicationCacheEnabled=true,

takesScreenshot=true}] at

sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at

sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

at

sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

at

org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:191)

at

org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)

at

org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)

at

org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:307)

at

org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:404)

at org.openqa.selenium.By$ByXPath.findElement(By.java:344) at

org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:299)

at seleniumtest.CaptchaTest.loginTest(CaptchaTest.java:41) at

seleniumtest.CaptchaTest.main(CaptchaTest.java:59) Caused by:

org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Unable

to locate element:

{“method”:”xpath”,”selector”:”//[@id=’forgotPassword’]/table/tbody/tr[5]/td[3]/img”}

Build info: version: ‘2.35.0’, revision: ‘8df0c6b’, time: ‘-08-12

15:43:19’ System info: os.name: ‘Windows 7’, os.arch: ‘amd64’,

os.version: ‘6.1’, java.version: ‘1.6.0_26’ Driver info:

driver.version: unknown at .FirefoxDriver.prototype.findElementInternal_(file:///C:/Users/lukup/AppData/Local/Temp/anonymous4043037924964932185webdriver-profile/extensions/fxdriver@/components/driver_component.js:8880)

at .fxdriver.Timer.prototype.setTimeout/<.notify>

如果觉得《selenium java 验证码_如何使用Selenium WebDriver和Java从图像(验证码)中读取文本》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。