1. <legend id='IQJ5E'><style id='IQJ5E'><dir id='IQJ5E'><q id='IQJ5E'></q></dir></style></legend>

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

      1. <small id='IQJ5E'></small><noframes id='IQJ5E'>

      2. 如何在 Selenium 中获得“nth-of-type"

        时间:2023-09-12

        • <legend id='GVoIc'><style id='GVoIc'><dir id='GVoIc'><q id='GVoIc'></q></dir></style></legend>
            <bdo id='GVoIc'></bdo><ul id='GVoIc'></ul>

              <tbody id='GVoIc'></tbody>
            <tfoot id='GVoIc'></tfoot>
              • <small id='GVoIc'></small><noframes id='GVoIc'>

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

                  本文介绍了如何在 Selenium 中获得“nth-of-type"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在使用 Selenium Webdriver 来检查这个特定段落的文本(此处以蓝色突出显示的那个):

                  I'm using Selenium Webdriver to check the text of this particular paragraph (the one highlighted in blue here):

                  但我如何查询"该段落?

                  But how do I 'query' that paragraph?

                  这是我正在尝试的(不工作):

                  This is what I'm trying (not working):

                      def test_intro_text(self):
                         """Test that intro text is expected text"""
                         container = self.browser.find_element_by_id('visual-17')
                         hed_dek_wrapper = container.find_element_by_class_name('hed-dek-wrapper')
                         intro_text = hed_dek_wrapper.findElement('p:nth-of-type(2)')
                         self.assertIn(
                          'Over the past 20 years, we have seen an evolution.',
                          intro_text.text
                         )
                  

                  我收到此错误:AttributeError: 'WebElement' object has no attribute 'findElement'

                  I'm getting this error: AttributeError: 'WebElement' object has no attribute 'findElement'

                  推荐答案

                  findElement() 不是 Python.请尝试以下方法:

                  findElement() is not a Python. Try below instead:

                  intro_text = hed_dek_wrapper.find_element_by_css_selector('p:nth-of-type(2)')
                  assert 'Over the past 20 years, we have seen an evolution.' in intro_text.text
                  

                  这篇关于如何在 Selenium 中获得“nth-of-type"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:带有基于文件的电子邮件后端服务器的 Django 测试 下一篇:如何在 Robot Framework 中将数据附加到 csv 文件?

                  相关文章

                  最新文章

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

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