我如何使用硒c#在input-select(React.js字段)中设置值?

问题描述 投票:2回答:1

人。

我没有使用硒c#获得输入选择值(React.js字段)。该字段获取服务的值。

Obs:我尝试使用SendKeys命令填充字段,但我不正确。

这是HTML代码:

<div class="Select selectbox-select Select--single is-clearable is-searchable"><div class="Select-control"><span class="Select-multi-value-wrapper" id="react-select-2--value"><div class="Select-placeholder">Selecione...</div><div class="Select-input" style="display: inline-block;"><style>input#undefined::-ms-clear {display: none;}</style><input role="combobox" aria-expanded="false" aria-owns="" aria-haspopup="false" aria-activedescendant="react-select-2--value" value="" style="width: 5px; box-sizing: content-box;"><div style="position: absolute; top: 0px; left: 0px; visibility: hidden; height: 0px; overflow: scroll; white-space: pre; font-size: 16px; font-family: roboto-regular, sans-serif; font-weight: 400; font-style: normal; letter-spacing: normal; text-transform: none;"></div></div></span><span class="Select-arrow-zone"><span class="Select-arrow"></span></span></div></div>

<div class="Select selectbox-select Select--single is-clearable is-searchable has-value"><div class="Select-control"><span class="Select-multi-value-wrapper" id="react-select-2--value"><div class="Select-value"><span class="Select-value-label" role="option" aria-selected="true" id="react-select-2--value-item">000001 - EST GO</span></div><div class="Select-input" style="display: inline-block;"><style>input#undefined::-ms-clear {display: none;}</style><input role="combobox" aria-expanded="false" aria-owns="" aria-haspopup="false" aria-activedescendant="react-select-2--value" value="" style="width: 5px; box-sizing: content-box;"><div style="position: absolute; top: 0px; left: 0px; visibility: hidden; height: 0px; overflow: scroll; white-space: pre; font-size: 16px; font-family: roboto-regular, sans-serif; font-weight: 400; font-style: normal; letter-spacing: normal; text-transform: none;"></div></div></span><span class="Select-clear-zone" title="Clear value" aria-label="Clear value"><span class="Select-clear">×</span></span><span class="Select-arrow-zone"><span class="Select-arrow"></span></span></div></div>

这是我的代码:

//ParametersPage.cs
 public void preencherCampoProduto(string produto)
        {
            inputSelectProduto.Clicks();
            IWebElement dropdownValue = retornaXpathCamposInputSelect(produto);
            dropdownValue.Clicks();
        }

public IWebElement retornaXpathCamposInputSelect(string valor)
        {
            return driver.FindElement(By.XPath("//div[contains(text(),'" + valor + "')]"));
        }

//ParametersTest.cs
        [TestMethod]
        public void OLE_testParametrosPreencherConvenio()
        {
            autenticacao.RealizarAutenticacao(usuarioCorreto, senhaCorreta);
            paginaInicial.acessarMenuRemuneracaoCadastroListagem();
            parametro.preencherCampoConvenio("005045 - CARBEL");
            //Assert.IsTrue(alerta.MensagemValidacao().Contains(MSG_RelatorioDataInicioFimForaLimite));
        }

谢谢,人们!!

selenium selenium-webdriver selenium-chromedriver selenium-rc selenium-grid
1个回答
0
投票

尝试使用Actions类:

IWebElement myElement = Driver.Instance.FindElement(By.XPath(“ // * [@ id ='field_” + SetEnvironmentJourney.EnvironmentControlId +“ _” + elementId +“']”)));动作=新动作(Driver.Instance);act.MoveToElement(myElement).Click()。Build()。Perform();

            IWebElement myItem = myElement.FindElement(By.XPath("//div[contains(text(),'" + p + "')]"));
            act.Click(myItem).Build().Perform();
© www.soinside.com 2019 - 2024. All rights reserved.