到目前为止我得到了什么:
def picture(self):
path = "/home/user/Desktop/cat.jpg"
path2 = "/home/user/Desktop/puppy.jpg"
pictureName = self.driver.find_element_by_xpath('//*[@id="easSettingAvatar"]')
self.captureScreen('picture', 1)
editPhoto.send_keys(path)
time.sleep(5)
print(pictureName)
self.captureScreen('picture', 2)
editPhoto.send_keys(path2)
time.sleep(5)
print(pictureName)
所以基本上,当我选择包含src的元素的CSS或Xpath时,它会打印完全不同的信息,如:
<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="bba710d8-ac5e-4e96-b946-14b3eda53cca", element="6d243513-8109-495e-a7a4-e4d218bbbd9a")>
答案 0 :(得分:0)
您必须打印WebElement的属性,而不是打印WebElement。
def picture(self):
path = "/home/user/Desktop/cat.jpg"
path2 = "/home/user/Desktop/puppy.jpg"
pictureName = self.driver.find_element_by_xpath('//*[@id="easSettingAvatar"]')
self.captureScreen('picture', 1)
editPhoto.send_keys(path)
time.sleep(5)
print(pictureName.get_attribute('outerHTML'))
print(pictureName.get_attribute('src'))
self.captureScreen('picture', 2)
editPhoto.send_keys(path2)
time.sleep(5)
结果应为
<img id="easSettingAvatar" src="eas.eightdevelopment.net/getAvatar/…;
eas.eightdevelopment.net/getAvatar/…