Selenium Webdriver 拼写检查

qae*_*epk 3 java selenium-webdriver

是否可以使用 selenium webdriver 对网页中显示的内容进行拼写检查。或者您可以建议任何相同的 API 吗?问候,埃利亚斯

Lit*_*nda 6

尝试使用 Google API 进行拼写检查。解决方案适用于java - https://code.google.com/p/google-api-spelling-java/

(以下内容来自链接)

示例代码:

SpellChecker checker = new SpellChecker();
SpellResponse spellResponse = checker.check( "helloo worlrd" );
for( SpellCorrection sc : spellResponse.getCorrections() )
System.out.println( sc.getValue() );
Run Code Online (Sandbox Code Playgroud)

这将打印文本“hello world”的所有可用更正。

还可以为请求设置更多选项,

// Proxy settings
Configuration config = new Configuration();
config.setProxy( "my_proxy_host", 8080, "http" );

SpellChecker checker = new SpellChecker( config );
checker.setOverHttps( true ); // Use https (default true from v1.1)
checker.setLanguage( Language.ENGLISH ); // Use English (default)

SpellRequest request = new SpellRequest();
request.setText( "helloo helloo worlrd" );
request.setIgnoreDuplicates( true ); // Ignore duplicates

SpellResponse spellResponse = checker.check( request );

for( SpellCorrection sc : spellResponse.getCorrections() )
System.out.println( sc.getValue() );
Run Code Online (Sandbox Code Playgroud)

更新:发现更多拼写检查器:

  1. JSpell - https://www.jspell.com/java-spell-checker.html
  2. JOrtho(免费)- http://jortho.sourceforge.net/
  3. Jazzy(免费)- http://sourceforge.net/projects/jazzy/