How to read the text from image (captcha) by using Selenium WebDriver with Java

后端 未结 7 998
囚心锁ツ
囚心锁ツ 2020-12-15 02:52

I have registration webpage but in last captcha is displaying..

I am not able to read the text from image. I am going to mention the code and output ..

<         


        
相关标签:
7条回答
  • 2020-12-15 03:33

    The forgot password form is in an iframe. That is the reason for selenium not finding the element. You need to switch to the iframe holding the form first, and then run your findelement. Your xpath is correct.

    Use driver.switchTo().frame(arg0) for switching into the frame. See javadoc here

    To get the captcha text, I didn't understand what you meant by 'store the test and compare'. Ideally you shouldn't be able to read the text from the captcha(As others have mentioned). One alternative approach I have seen is, storing the captcha value as alt text in the development and QA environment. So that you can read it and enter in the textbox. When the code goes to production or any outside environment, this alt text can be removed.

    0 讨论(0)
提交回复
热议问题