Changing language typing direction using selenium
Question: I am trying to change the typing direction of text using selenium Python to
right to left.

The normal Key sequence in the keyboard for that is CTRL+SHIFT (both right).

I have tried the following:

    
    
       from selenium.webdriver.common.keys import Keys
       from selenium.webdriver.support.ui import WebDriverWait
       from selenium.webdriver.support import expected_conditions as EC
       from selenium.webdriver import ActionChains
    
       def testLangDirChange(self):      
            self.driver.get("http://unixpapa.com/js/testkey.html")
            XPathTB='//textarea[@name="t"]'
            WebDriverWait(self.driver, 15).until(EC.presence_of_element_located((By.XPATH, XPathTB)))
            TB=self.driver.find_element_by_xpath(XPathTB)
            TB.click()
            actionChains=ActionChains(self.driver)
            actionChains.key_down(Keys.CONTROL).key_down(Keys.SHIFT).key_up(Keys.CONTROL).key_up(Keys.SHIFT).perform()
    

I see the correct Key sequence in the tester, but the typing direction does
not change (I still get left to right).

I also tried:

    
    
    firefoxProfile.native_events_enabled = False
    firefoxProfile.set_preference("intl.accept_languages", 'he-IL')
    

But it did not help.

(You must have a right to left keyboard layout such as Hebrew in order to test
this)

**UPDATE 1** :

I just enabled the following checkboxes on the testing site: modifiers, DOM 3,
old DOM 3 and compared the two outputs. what I see is that in the selenium
typing it is location=1 and in the keyboard test it is location=2.

Maybe Selenium types LEFT SHIFT when I do Keys.SHIFT(although the key LEFT
SHIFT is separately specified in Keys)?

**UPDATE 2:**

I found inside the module selenium.webdriver.common.keys.Keys the following:

    
    
    SHIFT        = '\ue008'
    LEFT_SHIFT   = SHIFT
    

so they are indeed defined the same. how do I specify RIGHT SHIFT in there?


Answer: I'm not really sure your WebDriver can send commands to OS level, I think what
it does is to operate within the browser only. Instead why don't you try
inputting the other language directly with sendKeys(otherLang) ?

