'How to select option from dropdown with Selenium when this element is not defined in HTML structure

I need to submit entered address into Google maps. After entered text into Search field dropdown with addresses is shown. This dropdown is not defined in html structure and I can not operate with it via xpath or css selectors.

enter image description here

I have tried to do it via WebDriverKeys() but it was not helped:

    public function enterTextIntoFieldMap(WebDriverBy $element, string $text)
    {
        try{
            $this->client->findElement($element)->clear()->sendKeys($text);
            $this->client->getKeyboard()->pressKey(WebDriverKeys::PAGE_DOWN);
            $this->client->getKeyboard()->pressKey(WebDriverKeys::ENTER);
            sleep(2);
        }catch (WebDriverException $exception){
            Assert::fail("Impossible to enter text into field");
        }
    }

Please, advise, how to select any option from dropdown in this situation.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source