def m_insertAdjacentHTML(self): # 插入邻近的HTML position = r.choice( ['beforebegin', 'afterbegin', 'beforeend', 'afterend']) tag = r.HTMLTags() # TODO:这里不支持script标签,查明原因 有可能是浏览器的问题 while tag == "script": tag = r.HTMLTags() text = "<%s>%s</%s>" % (tag, r.DOMString(r.zint(256)), tag) return "'%s',\"%s\"" % (position, text)
def m_getElementsByTagName(self): tagName = r.HTMLTags() return "'%s'" % tagName
def m_querySelector(self): # 找到一个后就返回节点对象 selectors = randoms.choice( [randoms.HTMLTags(), randoms.Element(), "*"]) return "'%s'" % selectors
def m_querySelectorAll(self): # 找出所有匹配的节点并返回数组 selectors = randoms.choice( [randoms.HTMLTags(), randoms.Element(), "*"]) return "'%s'" % selectors
def m_queryAll(self): n = randoms.choice([randoms.HTMLTags(), randoms.Element(), "'*'"]) return "'%s'" % n