第十期_selenium 进阶_20190728

参考连接

定位

    def find_element(self, by=By.ID, value=None):
        """
        Find an element given a By strategy and locator. Prefer the find_element_by_* methods when
        possible.

        :Usage:
            element = driver.find_element(By.ID, 'foo')

        :rtype: WebElement
        """
        if self.w3c:
            if by == By.ID:
                by = By.CSS_SELECTOR
                value = '[id="%s"]' % value
            elif by == By.TAG_NAME:
                by = By.CSS_SELECTOR
            elif by == By.CLASS_NAME:
                by = By.CSS_SELECTOR
                value = ".%s" % value
            elif by == By.NAME:
                by = By.CSS_SELECTOR
                value = '[name="%s"]' % value
        return self.execute(Command.FIND_ELEMENT, {
            'using': by,
            'value': value})['value']

CSS

不具备title属性

具备title属性

CSS XPATH
.title a //div/a ]
a [attribute*=“subString” ] //tag[contains(@attribute, “sub”) ]

休息时间 4:10分

作业1 (完成)

课后作业

– 以testerhome网站作为待测对象

  • 最新发布的帖子浏览
  • 社区访问霍格沃兹测试学院,断言未登录是被拒绝的
  • 错误用户名和密码登陆
  • 搜索”测试媛“,找到成立的那个帖子,进去后断言标题与搜索出来的标题是对应的

把代码和allure的截图,贴到回复里