problem with Apache Tika Language detection tool

27 views
Skip to first unread message

Narmatha Priya

unread,
Jul 8, 2022, 4:29:45 AM7/8/22
to Selenium Users
Hi everyone,

I tried the below code for LanguageDetection in selenium webdriver.


import java.io.IOException;
import org.apache.tika.exception.TikaException;
import org.apache.tika.language.LanguageIdentifier;
import org.xml.sax.SAXException;
public class LanguageDetection {
public static void main(String args[])throws IOException, SAXException, TikaException
{
LanguageIdentifier identifier = new LanguageIdentifier("option");
String language = identifier.getLanguage();
System.out.println("Language of the given content is : " + language);
}
}


Output : Language of the given content is : fr

Here, it displays FR but its same in EN also but its not display EN.  I want to check the text "option" is English or not. So Can someone tell me how to resolve this issue please?

Thanks,
Narmatha R

suhail shaik

unread,
Jul 13, 2022, 11:32:44 PM7/13/22
to seleniu...@googlegroups.com

I am getting this error and I am not getting any solutions. I have chosen the proper root selector and model. I believe I have added all the required dependencies. I am trying to automate a test case with angular.

I already raised this issue in stackframe below is the link.

https://stackoverflow.com/questions/72938900/getting-this-error-org-openqa-selenium-javascriptexception-javascript-error-a

My code is as follows.

WebElement stateSelect = driver.findElement(ByAngular.withRootSelector("\"app-create-customers\"").model("state"));

The error log is as follows.

org.openqa.selenium.JavascriptException: javascript error: angular is not defined
  (Session info: chrome=103.0.5060.114)
Build info: version: '4.2.2', revision: '683ccb65d6'
System info: host: 'DESKTOP-UPVJF2U', ip: '192.168.0.132', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '18.0.1.1'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [7c6f180eaae1b4997e8c2c08aa4bc0ed, executeScript {script=var using = arguments[0] || document;
var rootSelector = '"app-create-customers"';
var model = 'state';

var getNg1Hooks = function(selector, injectorPlease) {
  function tryEl(el) {
    try {
      if (!injectorPlease && angular.getTestability) {
        var $$testability = angular.getTestability(el);
        if ($$testability) {
          return {$$testability: $$testability};
        }
      } else {
        var $injector = angular.element(el).injector();
        if ($injector) {
          return {$injector: $injector};
        }
      }
    } catch(err) {}
  }
  function trySelector(selector) {
    var els = document.querySelectorAll(selector);
    for (var i = 0; i < els.length; i++) {
      var elHooks = tryEl(els[i]);
      if (elHooks) {
        return elHooks;
      }
    }
  }

  if (selector) {
    return trySelector(selector);
  } else if (window.__TESTABILITY__NG1_APP_ROOT_INJECTOR__) {
    var $injector = window.__TESTABILITY__NG1_APP_ROOT_INJECTOR__;
    var $$testability = null;
    try {
      $$testability = $injector.get('$$testability');
    } catch (e) {}
    return {$injector: $injector, $$testability: $$testability};
  } else {
    return tryEl(document.body) ||
        trySelector('[ng-app]') || trySelector('[ng\\:app]') ||
        trySelector('[ng-controller]') || trySelector('[ng\\:controller]');
  }
}

  using = using || document;

  if (angular.getTestability) {
    return getNg1Hooks(rootSelector).$$testability.
        findModels(using, model, true);
  }
  var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-', 'ng\\:'];
  for (var p = 0; p < prefixes.length; ++p) {
    var selector = '[' + prefixes[p] + 'model="' + model + '"]';
    var elements = using.querySelectorAll(selector);
    if (elements.length) {
      return elements;
    }
  }
, args=[null]}]
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 103.0.5060.114, chrome: {chromedriverVersion: 103.0.5060.53 (a1711811edd7..., userDataDir: C:\Users\win10\AppData\Loca...}, goog:chromeOptions: {debuggerAddress: localhost:56971}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: WINDOWS, proxy: Proxy(), se:cdp: ws://localhost:56971/devtoo..., se:cdpVersion: 103.0.5060.114, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Session ID: 7c6f180eaae1b4997e8c2c08aa4bc0ed
    at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:200)
    at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:133)
    at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:53)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:184)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:167)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:142)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:588)
    at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:522)
    at com.paulhammant.ngwebdriver.ByAngularModel.getObject(ByAngularModel.java:43)
    at com.paulhammant.ngwebdriver.ByAngular$BaseBy.findElement(ByAngular.java:166)
    at org.openqa.selenium.remote.ElementLocation$ElementFinder$1.findElement(ElementLocation.java:136)
    at org.openqa.selenium.remote.ElementLocation.findElement(ElementLocation.java:80)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:406)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:398)
    at com.vilcart.app.ReadLogin.ReadData(ReadLogin.java:136)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
... Removed 28 stack frames
I have tested it with firefox driver . I am getting the same problem.
Please let me know any suggestions.

Regards,
Suhail Shaik
Reply all
Reply to author
Forward
0 new messages