【问题标题】:Trying to select a check box but not getting selected试图选中一个复选框但没有被选中
【发布时间】:2021-10-02 02:22:42
【问题描述】:
<div class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable" tabindex="-1" role="dialog" aria-labelledby="ui-dialog-title-imageModel" style="display: block; z-index: 1002; outline: 0px; height: auto; width: 700px; top: 225.5px; left: 278.5px;"><div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix"><span class="ui-dialog-title" id="ui-dialog-title-imageModel">ATTENTION TAX PAYERS!!!!!</span><a href="#" class="ui-dialog-titlebar-close ui-corner-all" role="button" style="display: none;"><span class="ui-icon ui-icon-closethick">close</span></a></div><div id="imageModel" class="ui-dialog-content ui-widget-content" style="width: auto; min-height: 0px; height: 92.4px;" scrolltop="0" scrollleft="0">
    <ul><li class="redFont"> Please insist on getting Form 16/16A from your Deductor downloaded only from Traces.Valid form 16/16A.<a href="http://contents.tdscpc.gov.in/images/third-party-form-26AS.png" target="_blank"><i><u> click here.</u></i></a></li></ul>
    <div class="floatLeft margintop20"><input type="checkbox" id="Details" name="Details" onclick="checkModal('modalPagee')"> I agree to the usage and acceptance of Form 16 / 16A generated from TRACES</div>
    <div class="floatLeft margintop20">
&nbsp;&nbsp;&nbsp;
    <input value="Proceed" type="button" class="button" id="btn" disabled="disabled" onclick="goCancel()">  
   </div>
   </div></div>

这是我正在处理的 HTML 代码,在这里我想选择复选框类型的输入元素,当我尝试它时

check_box = find_element_by_id("Details").click()我没有选择它。

如果需要更多详细信息

"https://www.incometax.gov.in/iec/foportal"请访问本站,

当在login, goto -&gt; e-file -&gt; income_tax_returns -&gt; view for 26as 和continue 之后,我们将得到another window opened 并在pop up 中得到popup,我们需要select the checkbox.

【问题讨论】:

    标签: python selenium automation


    【解决方案1】:

    详情在新标签中,您需要像下面这样切换焦点:

    wait = WebDriverWait(driver, 10)
    new_handle = driver.window_handles
    print(len(new_handle))
    driver.switch_to.window(new_handle[1])
    
    wait.until(EC.element_to_be_clickable((By.ID, "Details"))).click()
    

    【讨论】:

      【解决方案2】:

      试试:

      check_box = find_element_by_xpath('//*[@id="Details"]').click()
      

      【讨论】:

      • 不要忘记使用带有元素选择的驱动程序。
      猜你喜欢
      • 1970-01-01
      • 2014-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-05
      • 1970-01-01
      相关资源
      最近更新 更多