TransWikia.com

Selenium - Unable to select the dropdown value inside shadow element

Software Quality Assurance & Testing Asked by Sinu Reddy on January 27, 2021

I am trying to select the drop-down value inside my shadow element using the below code, I went to the last point but the selection has not happened.

I want to select any dropdown item from the screen based on text (trip.com, priceline.com, etc), please help.

WebElement shadowRoot1 = expandRootElement(root1);
    
WebElement root2 = shadowRoot1.findElement(By.id("hotels-search"));
WebElement shadowRoot2 = expandRootElement(root2);
    
WebElement root3 = shadowRoot2.findElement(By.id("detail"));
WebElement shadowRoot3 = expandRootElement(root3);
    
WebElement root4 = shadowRoot3.findElement(By.id("rates"));
WebElement shadowRoot4 = expandRootElement(root4);
WebElement root5 = shadowRoot4.findElement(By.tagName("hotel-rates-sort-bar"));
WebElement shadowRoot5 = expandRootElement(root5); 
WebElement element = shadowRoot5.findElement(By.cssSelector("#__providersDropdown > div.dropdown > div"));  
Select select= new Select(element);
select.selectByIndex(2);

My elements in the below screenshot
Screenshot of HTML code

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP