phantomjs.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:trackship 作者: nabeelio 项目源码 文件源码
def fill_form(self, fields=(), submit=True):
        """
        Fill in a form and press enter on last
        :param fields: list of tupules:
            (input_id, value),
            (input_id, value)
        :return:
        """
        elem = None
        for input_id, value in fields:
            if '//' in input_id:
                find = input_id
            else:
                find = "//input[@id='{id}']".format(id=input_id)

            elem = self.find_element(find)
            if elem.tag_name == 'select':
                select = Select(elem)
                select.select_by_visible_text(value)
            else:
                elem.send_keys(value)

        if elem and submit:
            elem.send_keys(Keys.ENTER)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号