-3

I'm using Behat with Mink functions and some custom functions to automate some websites. I hit a bump where I need to click 2 options from a list. Manually I need to press the "Control" button to select the second option. I'm trying to find help here to do the same with the automation tool. All our other functions in the Mink library were developed in PHP, hence I need some code in php.

  • Welcome SO, Please read https://stackoverflow.com/help/how-to-ask then modify your question. So that we can help. – RopAli Munshi Jan 30 '19 at 16:10
  • Can you clarify your question? According to the title, you want to press some keys, while you are refering to selection of options in your text. Additionally, what have you tried so far? Have you tried looking up your use case in the documentation? – Nico Haase Jan 30 '19 at 16:23
  • Lets say I have a list of items 1 through 10 When I manually want to select 2 options out of 10, I select Option4 then I press the Ctrl key and select Option 6 How can I press ctrl button using php – KRISHNA KATAMANENI Jan 30 '19 at 16:32
  • I found this one: code: /** * Presses specific keyboard key. * * param mixed $char could be either char ('b') or char-code (98) * param string $modifier keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta') */ public function keyPress($char, $modifier = null) { $this->getSession()->getDriver()->keyPress($this->getXpath(), $char, $modifier); } Not sure how to pass "ctrl" into the statement. – KRISHNA KATAMANENI Jan 30 '19 at 17:09

1 Answers1

0

I think there is a misconception here. When using Behat plus Mink you don't have to emulate pressing a key to select multiple options from an options list. Mink's selectOption() method has a bool parameter multiple - set it to true when selecting the second option. See the documentation / source of class NodeElement for details.