首页 > 解决方案 > 如何截取验证码并将其放入 JFrame

问题描述

我正在开发我的第一个 java 软件作为项目,使用我从大学学到的东西。我正在尝试将这个网站转换为学生使用它来获得结果的软件。

对不起,该网站是法语,请使用谷歌翻译页面。

网址:https ://www2.inscription.tn/ORegMx/servlet/AuthentificationEtud?ident=cin

该网站有一个验证码,用户需要看到它才能编写它。该链接需要加载一次,因此验证码不会更改。所以我正在考虑截取打开链接的验证码并将图像放入JFrame.

请在代码前检查设计

在此处输入图像描述

WebDriver driver = new HtmlUnitDriver();
driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS);
driver.navigate().to("https://www4.inscription.tn/ORegMx/servlet/AuthentificationEtud?ident=cin");              


WebElement c = driver.findElement(By.name("cin"));
WebElement d = driver.findElement(By.id("dn"));
WebElement cap = driver.findElement(By.id("cincap"));

String cin = CIN.getText();
String date = daten.getText();
String capp = code.getText();

// fill the fields
c.sendKeys(cin);
d.sendKeys(date);
cap.sendKeys(capp);

// Now submit the form. WebDriver will find the form for us from the element
cap.submit();

我可以在没有 Firefox 或 google chrome 的情况下获取屏幕截图吗?只使用 HtmlUnitDriver?请有人告诉我该怎么做,在获取验证码的屏幕截图(alt capito 的验证码元素)后,我该如何将其放入JFrame

我在eclipse中使用windowbuilder pro。

标签: javaselenium-webdriver

解决方案


推荐阅读