用硒声明页面的背景图像 [英] Asserting the background image of a page with selenium

查看:94
本文介绍了用硒声明页面的背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,用户可以在其中更改其个人资料页面的背景图像.因此,我没有断言,当用户更改图像时,图像实际上会更改.我无法终生想出一个CSS选择器或xpath来完成这项工作.这是我拥有的HTML:

I have an app in which the user can change the background image of their profile page. Therefore, I wasnt to assert that, when the user changes the image, the image actually changes. I can't for the life of me figure out a css selector or xpath to do the job. This is the HTML I have:

<body style="background:#FFFFFF url(/uploads/images/000/000/002/original.png?1257966819) no-repeat 0 0;" class="users users-show-edit layout-main-with-sidebar" id="users-edit">

有没有建议?

推荐答案

我最终还是这么做了,虽然有点骇人听闻,但确实可以做到:

I went with this in the end, bit of a hack, but does the job:

  html = browser.get_html_source
  assert html.include?("#{@background.background_image.url}")

这篇关于用硒声明页面的背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆