2022-07-30

自动化框架实操演示

1.添加头像

1、送货 ---高级成员 

1. 使用任何用户登录并转到高级会员

2. 右键单击并检查带有Juice Shop 徽标的送货箱的图像。五个 assets/public/images/JuiceShop_Logo.png以不同的大小和位置加载到 SVG 图形上。

3. main.js在浏览器中打开DevTools 并搜索与该页面和 SVG 图像相关的相应 Angular 控制器代码  搜索assets/public/images/JuiceShop_Logo.png

4. 前后找到application.logogetApplicationConfiguration(),testDecal!开发人员似乎使用它来测试 SVG 上的叠加图像,但在上线之前忘记将其删除!啊!

5. 尝试该testDecal参数,例如通过访问 http://localhost:3000/#/deluxe-membership?testDecal=test。您会注意到盒子上的徽标现在已经消失或显示损坏的图像符号。


思路:把png换了就 行。 

使用网上地址:搜索--查看图片http://img.crcz.com/allimg/201911/26/1574765536225916.jpg 

换一个本地,网上不都行,估计是网站做限制,有白名单。加了安全策略。

1. 尝试该testDecal参数,例如通过访问 http://localhost:3000/#/deluxe-membership?testDecal=test。您会注意到盒子上的徽标现在已经消失或显示损坏的图像符号。 

让我们将您重定向到我们的加密货币地址之一 

重定向技术 

强制重定向到你不应该重定向到的页面 

1. 从导航栏中的GitHub按钮中选择应用程序中的一个重定向链接,例如 http://114.116.97.187:8001/redirect?to=https://github.com/bkimminich/juice-shop2. http://114.116.97.187:8001/redirect?to=https://cn.bing.com报406 Error: Unrecognized target URL for redirect.3. http://114.116.97.187:8001/redirect/报500 TypeError: Cannot read property of undefined (reading ‘includes’) 白名单(isRedirectAllowed)4. 制作一个重定向 URL,以便目标 URLto带有一个包含来自允许列表的 URL 的自己的参数,例如http://114.116.97.187:8002/redirect?to=http://kimminich.de?pwned=https://github.com/bkimminich/juice-shop5. https://bkimminich.github.io/?pwned=https://github.com/bkimminich/juice-shop你们自己写一个从juiceshop网站跳转到bing,taobao的http://114.116.97.187:8002/redirect?to=https://uland.taobao.com/sem/tbsearch?refpid=https://github.com/bkimminich/juice-shop 


http://114.116.97.187:8002/r通过juiceshop网站加一 个链接,点击直接进入,taobaoedirect?to=https:

修改这个链接的值,点击直接可以跳到 

//github.com/bkimminich/juice-shop?testDecal=../../../../redirect?to=https://placekitten.com/g/400/500?x=https://github.com/bkimminich/juice-shop 

?testDecal=../../../../redirect?to=https://placekitten.com/g/400/500?x=https://github.com/bkimminich/juice-shop









2.解决使用未正确关闭的弃用B2B接口太挑战

上传xml文件。

https://pwning.owasp-juice.shop/appendi

代码如下

# Author: lindafang# Date: 7/28/22 11:44 AM# File: page_bing.pyfrom selenium.webdriver.common.by import Byfrom .base_action import BaseAction# 浏览器bing搜索页 中也要 有 公共的方法可 用class BingSearchPage(BaseAction):# 属性,元素,元素定位,如果定位换了,只换这里就行了,其他代码不用改search_text=By.ID,"sb_form_q"search_click=By.ID,"search_icon"# 方法 在搜索框中输入信息,def enter_keyword(self,text):self.input(self.search_text,text)# 方法 点击搜索图标def click_search(self):self.click(self.search_click)# 浏览器bing搜索结果页class SearchResultPage(BaseAction):# 没什么属性# 方法:返回要 验证元素文本def get_source(self):return self.driver.page_source 

x/solutions.html# Author: lindafang

# Date: 7/28/22 2:21 PM

# File: test_bing.py


import pytest

import allure

from selenium import webdriver

from .page_bing import BingSearchPage, SearchResultPage


初始化测试步骤


# 测试步骤:

# 初始化:

# 打开浏览器,关闭 浏览器

@pytest.fixture(scope="module")

def driver():

driver = webdriver.Chrome("/Users/lindafang/PycharmProjects/selenium_project0704/driver/chromedriver")

driver.implicitly_wait(30)

yield driver

driver.close()



def test_bing_soso(driver):

#    输入bing地址

driver.get("https://cn.bing.com")

#  初始化bing搜索 页

bing_search = BingSearchPage(driver)

# 在搜索框输入关键 字

bing_search.enter_keyword("selenium")

# 点击搜索

bing_search.click_search()

# 初始化结果页

result_page = SearchResultPage(driver)

# 断言搜索结果正确

assert "selenium" in result_page.get_source()# Author: lindafang

# Date: 7/28/22 2:21 PM

# File: test_bing.py


import pytest

import allure

from selenium import webdriver

from .page_bing import BingSearchPage, SearchResultPage



# 测试步骤:

# 初始化:

# 打开浏览器,关闭 浏览器(范围 :module,一个文件只执行一次)

@pytest.fixture(scope="module")

def driver():

driver = webdriver.Chrome("/Users/lindafang/PycharmProjects/selenium_project0704/driver/chromedriver")

driver.implicitly_wait(30)

# 执行第 一次 返回driver,当测试方法执行完成后再进入时从这句开始执行,直接执行关闭浏览器

yield driver

driver.close()

修改参数:


def test_bing_soso(driver):

# 参数driver是上面的方法名,通过传参的方式,在测试方法 前调用。

#    输入bing地址

driver.get("https://cn.bing.com")

#  初始化bing搜索 页

bing_search = BingSearchPage(driver)

# 在搜索框输入关键 字

bing_search.enter_keyword("selenium")

# 点击搜索

bing_search.click_search()

# 初始化结果页

result_page = SearchResultPage(driver)

# 断言搜索结果正确

assert "selenium" in result_page.get_source()





如图所示:


wait = WebDriverWait(driver, timeout=10, poll_frequency=1, ignored_exceptions=[ElementNotVisibleException, ElementNotSelectableException])element = wait.until(EC.element_to_be_clickable((By.XPATH, "//div")))

from selenium.webdriver.support  import expected_conditions as  EC

# 浏览器bing搜索结果页

class SearchResultPage(BaseAction):

#     没什么属性

#      方法:返回要 验证元素文本

def get_source(self,txt):

wait = WebDriverWait(self.driver, 10, 1)

element = wait.until(EC.visibility_of_element_located((By.PARTIAL_LINK_TEXT,txt)))

return element.text

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容