Android 在Python中打印元素的xpath文本

Android 在Python中打印元素的xpath文本,android,python,xpath,webdriver,Android,Python,Xpath,Webdriver,我需要打印xpath的文本,它是: def imageOrVideo(self): try: # camera1 = self.driver.find_element_by_id('com.eightdevelopment.eas.android:id/video_view') # source_code = camera1.get_attribute("class") camera1 = self.driver.find_element_

我需要打印xpath的文本,它是:

def imageOrVideo(self):
    try:
        # camera1 = self.driver.find_element_by_id('com.eightdevelopment.eas.android:id/video_view')
        # source_code = camera1.get_attribute("class")
        camera1 = self.driver.find_element_by_xpath('//android.widget.FrameLayout[1]/android.widget.FrameLayout[1]/android.view.ViewGroup[1]/android.widget.VideoView[1]')
        print(camera1)
    except NoSuchElementException:
        print("Status Not Visible!")
        return False
我试图打印类文本本身或xpath文本,但总是得到一些奇怪的结果。 有人能帮我吗?
谢谢

看到这个奇怪的输出可能会很有用。无论如何,如果您的xpath是正确的,那么您将得到一个webdriver元素(camera1)。所以,若要显示元素文本,需要使用text属性。尝试:打印camera1.text谢谢,问题是-文本是黑线。所以我需要找到一种方法,在不使用文本的情况下打印xpath本身。我认为不可能从WebElement对象获取xpath。然而,当您使用python时,您可以通过monkeypatching webdriver
find_element
方法来实现这一点,该方法将值存储在一些属性中,您可以稍后检索这些属性。