Search code examples
c#seleniumautomated-testsdropdowndevextreme

How to select a value from Devextreme dropdown with Selenium C#


I need to select values (any value from House_TypeList) from dropdown menu with NUnit or just pure selenium. . They are not seen in HTML. I have tried select by xpath, by name, by span contains etc etc, I tried sending down key. I have waited for the element to become visible. I am out of ideas. Nothing works. I have not tried yet moving the cursor and trying to select it by that, but had a few problems implementing it and having in mind my luck, not really believing it will work either..

I am a beginner here, maybe I did some mistakes there. But I successfully managed any other inputs, buttons, navigation..

I have checked other similar questions, but could not find the answer that would work for me.

Is it even possible here?

Source:

<div class="dx-item dx-box-item" style="display: flex; min-height: auto; flex-grow: 1; flex-shrink: 1;"
  <div class="dx-item-content dx-box-item-content" style="width: auto; height: auto; display: flex; flex-direction: column; flex-basis: 0px; flex-grow: 1;">
    <div class="dx-first-col dx-last-col dx-field-item dx-field-item-required dx-col-0 dx-flex-layout dx-label-h-align">
      <label class="dx-field-item-label dx-field-item-label-location-left" for="dx_dx-...._typeId">
        <span class="dx-field-item-label-content" style="width: 159px;">
          <span class="dx-field-item-label-text">Type:</span>
          <span class="dx-field-item-required-mark">&nbsp;*</span>
        </span>
      </label>
      <div class="dx-field-item-content dx-field-item-content-location-right">
        <div class="dx-textbox dx-texteditor dx-texteditor-empty dx-dropdowneditor-button-visible dx-widget dx-dropdowneditor-field-clickable dx-dropdowneditor dx-selectbox dx-validator dx-visibility-change-handler" id="slb_HouseManagement_EditHouse_TypeList">
          <div class="dx-dropdowneditor-input-wrapper dx-selectbox-container">
            <input type="hidden" value="" name="typeId">
            <div class="dx-texteditor-container">
              <input autocomplete="off" id="dx_dx-4e..._typeId" class="dx-texteditor-input" aria-haspopup="true" aria-autocomplete="list" type="text" readonly="" spellcheck="false" tabindex="0" aria-expanded="false" role="combobox" aria-required="true">
              <div data-dx_placeholder="Select..." class="dx-placeholder"></div>
              <div class="dx-texteditor-buttons-container">
                <div class="dx-dropdowneditor-button dx-button-normal dx-widget" type="button">
                  <div class="dx-button-content">
                    <div class="dx-dropdowneditor-icon"></div>
                  </div></div></div></div></div></div></div></div></div></div>

Solution

  • Done. Found it in Devextreme support, the user had a bit different problem, but it solved mine as well.

    IWebElement selectedItem = driver.FindElement(By.XPath("//div[@role='option']/div[text()='Apartment']"));
    selectedItem.Click();