1

macOS 10.14.3
Chrome 72.0.3626.96
Chromedriver 2.46

While trying to execute following code I receive an error:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.KeyEvent;
import java.util.concurrent.TimeUnit;

public class RobotTest {

    public WebDriver driver;
    public WebDriverWait wait;
    private static String filePath = System.getProperty("user.dir") + "\\images\\sw-test-academy.png";

    @BeforeMethod
    public void setup () {
        driver = new ChromeDriver();
        driver.navigate().to("https://blueimp.github.io/jQuery-File-Upload/");
        driver.manage().timeouts().pageLoadTimeout(15, TimeUnit.SECONDS);
        wait = new WebDriverWait(driver,10);
        driver.manage().window().maximize();
    }

    @Test
    public void robotTest () throws InterruptedException {
        //Click Image Upload
        wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".btn.btn-success.fileinput-button")));
        driver.findElement(By.cssSelector(".btn.btn-success.fileinput-button")).click();
        uploadFileWithRobot(filePath);
        Assert.assertTrue(wait.until(ExpectedConditions.visibilityOfElementLocated
                (By.cssSelector(".name"))).getText().equals("sw-test-academy.png"));
        //I added sleep to see the result with my eyes. If you want you can remove below line.
        Thread.sleep(2000);
    }

    @AfterMethod
    public void teardown () {
        driver.quit();
    }

    //File upload by Robot Class
    public void uploadFileWithRobot (String imagePath) {
        StringSelection stringSelection = new StringSelection(imagePath);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(stringSelection, null);

        Robot robot = null;

        try {
            robot = new Robot();
        } catch (AWTException e) {
            e.printStackTrace();
        }

        robot.delay(250);
        robot.keyPress(KeyEvent.VK_ENTER);
        robot.keyRelease(KeyEvent.VK_ENTER);
        robot.keyPress(KeyEvent.VK_CONTROL);
        robot.keyPress(KeyEvent.VK_V);
        robot.keyRelease(KeyEvent.VK_V);
        robot.keyRelease(KeyEvent.VK_CONTROL);
        robot.keyPress(KeyEvent.VK_ENTER);
        robot.delay(150);
        robot.keyRelease(KeyEvent.VK_ENTER);
    }
}

Error:

2019-02-12 12:08:49.264 java[21517:2034626] pid(21517)/euid(502) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!

1 Answer 1

1

It appears to be an issue with the chrome driver implementation for Mac OSX. Around High Sierra (10.13.0) it looks like Apple introduced increased logging for their Text Services Manager (TSM).

From the discussion on this (other library) around the same issue, I don't think it will have any functional issue (but is very annoying). https://github.com/processing/processing/issues/5462

Another developer here has gone into further detail about debugging the issue in his own code. https://indiestack.com/2018/08/let-it-rip/

My tests still run, despite the error. I think all we can do is wait for ChromeDriver to use the main thread for whatever bit of code is causing the error to be logged.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.