0

I have been trying to press (CTRL + ALT + 'f') after selecting a WebElement using selenium 3.5 on firefox quantum. This is the code I have written :

WebElement ele = m_driver.findElement(By.cssSelector(".tm-project-name"));
ele.click();
Actions act = new Actions(m_driver);
act.sendKeys(Keys.CONTROL).perform();
act.sendKeys(Keys.ALT).perform();
act.sendKeys("f").perform();

For performing this work I also tried this method

act.sendKeys(Keys.chord(Keys.CONTROL, Keys.ALT, "F")).build().perform();

Both of these methods works fine on chrome browser but fails to work in firefox quantum. Can anyone help me out on this issue.

Suraj Prakash
  • 41
  • 1
  • 10
  • 1
    For what purpose are you trying to pass control+Alt+"f"? – Pradeep hebbar Jan 18 '18 at 13:30
  • Instead of the whole `Actions act ... act.sendKeys("f").perform();` part, try to add after the click: `ele.sendKeys(Keys.chord(Keys.CONTROL, Keys.ALT, "F"));` – GalAbra Jan 18 '18 at 13:34
  • @Pradeephebbar I need to execute this in my application and highlight an element. – Suraj Prakash Jan 18 '18 at 15:18
  • @GalAbra I tried this also but this is not working in firefox quantum. – Suraj Prakash Jan 18 '18 at 15:18
  • What happens with the `Java` **`click()`**? Do you see any error? Update the error stack trace within the Question. Also update the purpose of `press (CTRL + ALT + 'f')`. – undetected Selenium Jan 18 '18 at 15:53
  • @DebanjanB I need to click on a web element that can be done by simply clicking on the locator value but in firefox quantum its not working. Beside that clicking can be done using (CTRL + ALT + 'f') so I am trying to perform that. No error in Java **click()**. It does not stuck at that point and moves to the next line. – Suraj Prakash Jan 19 '18 at 05:00
  • See, Java `click()` is quite proven and powerful. If it fails there would be some reasons. With out proper probe with `click()` and any valid reason it won't be a good idea to shift focus to other `click()`. Add a listener and try to see if you can catch up with whats wrong happening. – undetected Selenium Jan 19 '18 at 07:02

2 Answers2

1

You can try to pass control+Alt+"f" using Robot class , this will work in all browsers.

Try the below code.

Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_F);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_ALT);
robot.keyRelease(KeyEvent.VK_F);

Hope this will work for you.

Pradeep hebbar
  • 2,147
  • 1
  • 9
  • 14
  • Here are the needed imports... for anyone trying : 1) import java.awt.Robot; 2) import java.awt.event.KeyEvent; – AlexD Aug 28 '21 at 00:04
0
WebElement ele = m_driver.findElement(By.cssSelector(".tm-project-name"));
ele.send_keys(Keys.SHIFT+Keys.CONTROL+'f');

I normally write in python, and I checked it in my IDE before I submitted...Python works... thinking this is the C# version

Chris Brocious
  • 161
  • 1
  • 3
  • 13