Using Selenium's Python API - How do I get the number of rows in a table?

前端 未结 2 726
萌比男神i
萌比男神i 2021-01-23 19:10

How do I get the number of rows in an HTML table using Selenium\'s Python API?

I\'d have a 2 column table of Keys and Values and I\'d like to read it into a dictionary.

2条回答
  •  萌比男神i
    2021-01-23 19:44

    from the driver:

    def get_xpath_count(self,xpath):
        """
        Returns the number of nodes that match the specified xpath, eg. "//table" would give
        the number of tables.
    
        'xpath' is the xpath expression to evaluate. do NOT wrap this expression in a 'count()' function; we will do that for you.
        """
        return self.get_number("getXpathCount", [xpath,])
    

提交回复
热议问题