1+ """ Image-saving with "save_element_as_image_file()".
2+
3+ Also shown are ways of ordering tests. (Currently commented out)
4+ For ordering tests, add the marker "@pytest.mark.run(order=NUM)"
5+ before a test definition or class definition.
6+ This changes the global test order when running "pytest".
7+ Eg: If you want a test to always run first before any test
8+ from all discovered files, add "@pytest.mark.run(order=0)".
9+ For local class/module test-ordering, name your tests
10+ using alphabetical order to set the order desired.
11+ Eg: "def test_AAAAA" will run before "def test_ZZZZZ".
12+ You can also add in numbers to force a specific order.
13+ Eg: "def test_1_ZZZ" will run before "def test_2_AAA".
14+ """
115import os
2- import pytest
16+ # import pytest # For ordering tests globally with @pytest.mark.run()
317from seleniumbase import BaseCase
418
519
620class ImageTests (BaseCase ):
7- @pytest .mark .run (order = 1 )
8- def test_pull_image_from_website (self ):
21+ # @pytest.mark.run(order=1)
22+ def test_1_save_element_as_image_file (self ):
923 """Pull an image from a website and save it as a PNG file."""
1024 self .open ("https://xkcd.com/1117/" )
1125 selector = "#comic"
@@ -15,8 +29,8 @@ def test_pull_image_from_website(self):
1529 self .assert_true (os .path .exists ("%s/%s" % (folder , file_name )))
1630 print ('\n "%s/%s" was saved!' % (folder , file_name ))
1731
18- @pytest .mark .run (order = 2 )
19- def test_add_text_overlay_to_image (self ):
32+ # @pytest.mark.run(order=2)
33+ def test_2_add_text_overlay_to_image (self ):
2034 """Add a text overlay to an image."""
2135 self .open ("https://xkcd.com/1117/" )
2236 selector = "#comic"
@@ -29,8 +43,8 @@ def test_add_text_overlay_to_image(self):
2943 self .assert_true (os .path .exists ("%s/%s" % (folder , file_name )))
3044 print ('\n "%s/%s" was saved!' % (folder , file_name ))
3145
32- @pytest .mark .run (order = 3 )
33- def test_add_text_overlay_to_page_section (self ):
46+ # @pytest.mark.run(order=3)
47+ def test_3_add_text_overlay_to_page_section (self ):
3448 """Add a text overlay to a section of a page."""
3549 self .open ("https://xkcd.com/2200/" )
3650 selector = "#middleContainer"
@@ -48,8 +62,8 @@ def test_add_text_overlay_to_page_section(self):
4862 self .assert_true (os .path .exists ("%s/%s" % (folder , file_name )))
4963 print ('\n "%s/%s" was saved!' % (folder , file_name ))
5064
51- @pytest .mark .run (order = 4 )
52- def test_add_text_overlay_to_full_page (self ):
65+ # @pytest.mark.run(order=4)
66+ def test_4_add_text_overlay_to_full_page (self ):
5367 """Add a text overlay to a full page."""
5468 self .open ("https://xkcd.com/1922/" )
5569 self .remove_element ("#bottom" )
0 commit comments