作用
语法格式
cy.location()
cy.location(key)
cy.location(options)
cy.location(key, options)
options:只有 timeout 和 log,不再展开讲了
正确写法
cy.location()
// 获取 host 值
cy.location('host')
// 获取 port 值
cy.location('port')
location 对象有哪些属性
- hash
- host
- hostname
- href
- origin
- pathname
- port
- protocol
- search
- toString
实际栗子
测试文件代码
测试结果
location() 命令的产物
总结
cy.location(“host”) 这样写只会返回对应属性的值