有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

如何在使用java使用WebDriver创建新的google帐户时读取图像框中的文本

如何在java中使用WebDriver创建新的google帐户时读取图像框中的文本。我正在用java中的WebDriver创建一个新的gmail帐户。我无法阅读图像框中的文本。有人能帮我解决这个问题吗

我使用的代码是:

driver = new InternetExplorerDriver();
driver.get("http://gmail.com");
Thread.sleep(10000);
driver.findElement(By.id("link-signup")).click();
Thread.sleep(10000);
driver.findElement(By.id("FirstName")).sendKeys("Swamy");
driver.findElement(By.id("LastName")).sendKeys("Kumar");
driver.findElement(By.id("GmailAddress")).sendKeys("Skumar081112");
driver.findElement(By.id("Passwd")).sendKeys("Swamy@123");
driver.findElement(By.id("PasswdAgain")).sendKeys("Swamy@123");
driver.findElement(By.xpath("//label[@id='month-label']/span/div
                         /div")).sendKeys("November");
driver.findElement(By.id("BirthDay")).sendKeys("16");
driver.findElement(By.id("BirthYear")).sendKeys("1978");
driver.findElement(By.xpath("//div[@id='Gender']/div/div")).sendKeys("Male");
driver.findElement(By.id("RecoveryPhoneNumber")).sendKeys("9000000000");
driver.findElement(By.id("RecoveryEmailAddress")).sendKeys("abc@gmail.com");
driver.findElement(By.id("HomepageSet")).click();
String imgmsg = driver.findElements(By.xpath("//div[@id='recaptcha_image']
                 /img")).toString();
System.out.println(imgmsg);

我们将感谢您的帮助


共 (1) 个答案

  1. # 1 楼答案

    你不能

    该文本被称为CAPTCHA,旨在阻止自动系统创建帐户(显然做得很好)

    A CAPTCHA (pron.: /ˈkæp.tʃə/) is a type of challenge-response test used in computing as an attempt to ensure that the response is generated by a human being. The process usually involves a computer asking a user to complete a simple test which the computer is able to grade. These tests are designed to be easy for a computer to generate but difficult for a computer to solve, but again easy for a human. If a correct solution is received, it can be presumed to have been entered by a human. A common type of CAPTCHA requires the user to type letters and/or digits from a distorted image that appears on the screen. Such tests are commonly used to prevent unwanted internet bots from accessing websites, since a normal human can easily read a CAPTCHA, while the bot cannot process the image letters and therefore, cannot answer properly, or at all. Although most CAPTCHAs are letter pictures randomly generated, many of them have become difficult even for a human to read , so picture CAPTCHAs were created in which a human is shown a simple test to show a picture of a certain animal (given few animal pictures), which is simple for a human being to process, and therefore easy to pick, while a bot cannot process and solve the question because although it can analyze the picture, it cannot easily guess the animal. The term "CAPTCHA" was coined in 2000 by Luis von Ahn, Manuel Blum, Nicholas J. Hopper, and John Langford (all of Carnegie Mellon University). It is an acronym based on the word "capture" and standing for "Completely Automated Public Turing test to tell Computers and Humans Apart". Carnegie Mellon University attempted to trademark the term on 15 October 2004,1 but the trademark application was abandoned on 21 April 2008.[2] A CAPTCHA is sometimes described as a reverse Turing test, because it is administered by a machine and targeted at a human, in contrast to the standard Turing test that is typically administered by a human and targeted at a machine.