AttributeError: 'NoneType' object has no attribute 'send_keys' 这个怎么处理?

path = ‘…/page/search.yaml’

def spets(self,path):
    with open(path) as f:

        stepss: list[dict]=yaml.safe_load(f)
        element:WebElement=None
        for spet in stepss:
            logging.info(spet)
            if 'by' in spet.keys():
                   element=self.find(spet['by'],spet['locator'])
            if 'action' in spet.keys():
                action=spet['action']
                if action == "click":
                    element.click()
                elif action in ["send", "input"]:
                    element.send_keys(action['value'])
                else:
                    element.text()

E AttributeError: ‘NoneType’ object has no attribute ‘send_keys’

我自己试试了一下,element是空,已解决

关闭