How to use keyboard events in MacAirbook

42 views
Skip to first unread message

Rashmi Upari

unread,
Jan 28, 2019, 11:34:51 PM1/28/19
to Selenium Users
Hello All,
 I am unable to use regular Robot class in MAC Airbook OS X(Mojave)
Can anyone please guide me how to perform keyboard events in macbook??

Thanks

Deepak Koul

unread,
Jan 29, 2019, 5:01:03 AM1/29/19
to seleniu...@googlegroups.com
Have you tried the actions library ?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fc06c0ee-2cd3-4d44-a16e-70d21655a53b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rashmi Upari

unread,
Jan 29, 2019, 7:42:02 AM1/29/19
to Selenium Users
yes, i have tried Actions library its not working...

rarunp04

unread,
Jan 29, 2019, 7:53:18 AM1/29/19
to seleniu...@googlegroups.com
Can you pls share the code, what scenario it is failing ?

Rashmi Upari

unread,
Jan 29, 2019, 11:48:48 PM1/29/19
to Selenium Users

Tried all methods that are commented...and later tried with applescript which worked but i would like to know if there is anyother way to use Robot class in MAC


public static void main(String[] args) throws Throwable {

// TODO Auto-generated method stub

System.setProperty("webdriver.chrome.driver", "/Users/rashmimohan/Desktop/Selenium_IDE/chromedriver");

WebDriver driver = new ChromeDriver();

//System.setProperty("webdriver.gecko.driver", "/Users/rashmimohan/Desktop/Selenium_IDE/geckodriver");

//WebDriver driver = new FirefoxDriver();

driver.get("https://www.phptravels.net/");

/*for(int row = 2; row<=2;row++)

{

for(int col = 1;col<=1;)

{

search_by_cityname(driver,excel_read(row,col));

//col++;

//click_cityname(driver,excel_read(row,col));

}

} */

WebElement city_text = driver.findElement(By.xpath("//*[@id=\"s2id_autogen8\"]/a/span[1]"));

city_text.click();

WebElement entername = driver.findElement(By.xpath("//*[@id=\"select2-drop\"]/div/input"));

entername.sendKeys("Bangalore");

//entername.sendKeys(Keys.ENTER);

Thread.sleep(1000);

Runtime.getRuntime().exec("osascript "+"/Users/rashmimohan/Desktop/Testingkeyboardevents.scpt");

//Keys.chord(Keys.ENTER);

//Keys.chord(Keys.COMMAND,"ENTER");

   

        //KeyEvent.KEY_PRESSED(Keys.ENTER);

//Thread.sleep(1000);

/*Robot r = new Robot();

r.delay(1000);

r.keyPress(KeyEvent.VK_ENTER);

r.keyRelease(KeyEvent.VK_ENTER);

/* String os = System.getProperty("os.name");

if (os.equals("WINDOWS")){

  Keys.chord(Keys.CONTROL, "a");

}else{

  Keys.chord(Keys.COMMAND.ENTER);

}*/

rarunp04

unread,
Jan 30, 2019, 12:48:34 AM1/30/19
to seleniu...@googlegroups.com
Is it working in Firefox or Safari? Then this is existing issue from 2012 .
please refer below discussion for reference :


Rashmi Upari

unread,
Jan 30, 2019, 1:07:21 AM1/30/19
to Selenium Users
using chrome...

rarunp04

unread,
Jan 30, 2019, 7:12:52 AM1/30/19
to seleniu...@googlegroups.com
I didnt check this, probably you may have to check if any settings has to be done in MAC OS for accepting KeyBoard Inputs.

Rashmi Upari

unread,
Jan 30, 2019, 11:35:21 PM1/30/19
to Selenium Users
Thanks for your time :)
Reply all
Reply to author
Forward
0 new messages