radiateboy/automagic

class name定位失败

LGTH opened this issue · 1 comments

LGTH commented

通过class name定位的元素失败,因为seleniumkeyword/Base.py中的封装的find_element函数调用了selenium.webdriver的原生find_element方法。
原生的

class By(object):
    ID = "id"
    XPATH = "xpath"
    LINK_TEXT = "link text"
    PARTIAL_LINK_TEXT = "partial link text"
    NAME = "name"
    TAG_NAME = "tag name"
    CLASS_NAME = "class name"
    CSS_SELECTOR = "css selector"

封装的元素为:

     class Element(models.Model):
        Element_Choice = (
            ('id', 'id'),
            ('name', 'name'),
            ('css selector', 'css selector'),
            ('xpath', 'xpath'),
            ('class_name', 'class name'),
            ('tag_name', 'tag name'),
            ('link_text', 'link text'),
            ('portial_link_text', 'portial link text')
        )

实际调用传参为class_name,dirver对象不识别,只有class name才是正确的,另外通过源码可以查看到,link_text、portial_link_text、xpath也是存在问题的。应该把Element中的改为如('class name', 'class name')。

感谢,已merge.