• <legend id='IkCBw'><style id='IkCBw'><dir id='IkCBw'><q id='IkCBw'></q></dir></style></legend>
    <i id='IkCBw'><tr id='IkCBw'><dt id='IkCBw'><q id='IkCBw'><span id='IkCBw'><b id='IkCBw'><form id='IkCBw'><ins id='IkCBw'></ins><ul id='IkCBw'></ul><sub id='IkCBw'></sub></form><legend id='IkCBw'></legend><bdo id='IkCBw'><pre id='IkCBw'><center id='IkCBw'></center></pre></bdo></b><th id='IkCBw'></th></span></q></dt></tr></i><div id='IkCBw'><tfoot id='IkCBw'></tfoot><dl id='IkCBw'><fieldset id='IkCBw'></fieldset></dl></div>

      <tfoot id='IkCBw'></tfoot>
      • <bdo id='IkCBw'></bdo><ul id='IkCBw'></ul>

      <small id='IkCBw'></small><noframes id='IkCBw'>

      1. 如何使用 Selenium 和 C# 通过元素 ID 属性单击单选

        时间:2023-06-03
        • <bdo id='752ee'></bdo><ul id='752ee'></ul>

            <i id='752ee'><tr id='752ee'><dt id='752ee'><q id='752ee'><span id='752ee'><b id='752ee'><form id='752ee'><ins id='752ee'></ins><ul id='752ee'></ul><sub id='752ee'></sub></form><legend id='752ee'></legend><bdo id='752ee'><pre id='752ee'><center id='752ee'></center></pre></bdo></b><th id='752ee'></th></span></q></dt></tr></i><div id='752ee'><tfoot id='752ee'></tfoot><dl id='752ee'><fieldset id='752ee'></fieldset></dl></div>

            <tfoot id='752ee'></tfoot>
              <tbody id='752ee'></tbody>

              <small id='752ee'></small><noframes id='752ee'>

                <legend id='752ee'><style id='752ee'><dir id='752ee'><q id='752ee'></q></dir></style></legend>

                1. 本文介绍了如何使用 Selenium 和 C# 通过元素 ID 属性单击单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正在尝试选择一个单选按钮和输入元素,它有一个组的 idIn_Group 的值.有 4 个不同的单选按钮具有相同的 id 但不同的值,因此我正在尝试选择我正在寻找的正确的单选按钮.

                  I am trying to select a radio button and input element, it has an id of group and value of In_Group. There are 4 different radio buttons with the same id but different values hence I am trying to select the correct one i am looking for.

                  <input class="custom-radio" id="group" name="group" type="radio" value="In_Group">
                  

                  我尝试过这样的事情:

                  driver.FindElement(By.XPath("//*[contains(@id='group' and @value='In_Group')]"))
                  

                  但是找不到元素,谁能帮帮我

                  But the element is not found could someone help me out

                  推荐答案

                  要定位元素,您可以使用以下任一方法 定位器策略:

                  To locate the element you can use either of the following Locator Strategies:

                  • CssSelector:

                  driver.FindElement(By.CssSelector("input#group[value='In_Group']"));
                  

                2. XPath:

                  driver.FindElement(By.XPath("//input[@id='group' and @value='In_Group']"));
                  

                3. 但是,由于它是一个 <input> 元素,并且您可能会在理想情况下与之交互,因此您必须诱导 WebDriverWait 用于所需的 ElementToBeClickable() 并且您可以使用以下任一 Locator Strategies:

                  However, as it is a <input> element and possibly you will interact with it ideally you have to induce WebDriverWait for the desired ElementToBeClickable() and you can use either of the following Locator Strategies:

                  • CssSelector:

                  new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("input.custom-radio#group[value='In_Group'][name='group']"))).Click();
                  

                4. XPath:

                  new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@id='group' and @value='In_Group'][@class='custom-radio' and @name='group']"))).Click();
                  

                5. 这篇关于如何使用 Selenium 和 C# 通过元素 ID 属性单击单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:是否有可以在 C# 中使用的类似 jQuery 的 CSS/HTML 选 下一篇:如何解码 JWT 令牌?

                  相关文章

                  最新文章

                  <small id='Pwpmn'></small><noframes id='Pwpmn'>

                  <i id='Pwpmn'><tr id='Pwpmn'><dt id='Pwpmn'><q id='Pwpmn'><span id='Pwpmn'><b id='Pwpmn'><form id='Pwpmn'><ins id='Pwpmn'></ins><ul id='Pwpmn'></ul><sub id='Pwpmn'></sub></form><legend id='Pwpmn'></legend><bdo id='Pwpmn'><pre id='Pwpmn'><center id='Pwpmn'></center></pre></bdo></b><th id='Pwpmn'></th></span></q></dt></tr></i><div id='Pwpmn'><tfoot id='Pwpmn'></tfoot><dl id='Pwpmn'><fieldset id='Pwpmn'></fieldset></dl></div>
                    <bdo id='Pwpmn'></bdo><ul id='Pwpmn'></ul>
                  <legend id='Pwpmn'><style id='Pwpmn'><dir id='Pwpmn'><q id='Pwpmn'></q></dir></style></legend>

                    1. <tfoot id='Pwpmn'></tfoot>