[QA] checking width in %

Jeff Hall jhall at wikimedia.org
Wed Jan 15 00:21:58 UTC 2014


I haven't had to create a test with this specific type of element 
before, but from some quick Googlin', it seems that there is no specific 
method available via the Selenium API to obtain the width as a 
percentage, so the consensus seems to be that you have to calculate the 
percentage yourself based on the maximum possible pixel width (after 
maximizing the browser window size with something like 
/@browser.window.maximize/)

- Jeff



On 1/14/14, 11:59 AM, Amir E. Aharoni wrote:
> Hi,
>
> In the new ContentTranslation extension we have a progress bar, which 
> is updated using the CSS width property. I wanted to test that it has 
> the correct value, so I used something like
> progress_bar_element.style("width").should == expected_width
>
> Surprisingly, this didn't work: It seems to return the computed value 
> in px, rather than the specified CSS value in %.
>
> For now I did this like this:
> on(ContentTranslationPage).progress_bar_element.attribute("style").should 
> match(/width: #{width};/)
>
> (See 
> https://gerrit.wikimedia.org/r/#/c/107357/4/tests/browser/features/step_definitions/special_content_translation_steps.rb 
> )
>
> Something tells me that there should be a better way. Can anybody 
> think of anything?
>
> Thanks!
>
> --
> Amir Elisha Aharoni · אָמִיר אֱלִישָׁע אַהֲרוֹנִי
> http://aharoni.wordpress.com
> ‪“We're living in pieces,
> I want to live in peace.” – T. Moore‬
>
>
> _______________________________________________
> QA mailing list
> QA at lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/qa

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wikimedia.org/pipermail/qa/attachments/20140114/fc12cc5d/attachment-0001.html>


More information about the QA mailing list