Monday , April 19 2021

seleniumbase / SeleniumBase, Hacker News


SeleniumBase Website Tours

SeleniumBase Tours utilize your choice of 4 different JavaScript libraries for prototyping walkthroughs, onboarding experiences, and digital adoption solutions on any website:
Shepherd,Bootstrap Tour,IntroJS, andHopscotch.
Choose your favorite one to use!

Example tour:

cd examples / tour_examples pytest

Creating a new tour:

To create a tour utilizing the Shepherd JS Library, use one of the following:

self.create_shepherd_tour ()


self.create_tour (theme="shepherd")

You can pass a custom theme to change the look & feel of Shepherd tours. Valid themes for Shepherd Tours aredark,light/arrows,default,square, andsquare-dark.

To create a tour utilizing the Bootstrap Tour Library, use one of the following:

self.create_bootstrap_tour ()


self.create_tour (theme="bootstrap")

To create a tour utilizing the Intro JS Library, use one of the following:

self.create_introjs_tour ()


self.create_tour (theme="introjs")

To create a tour utilizing the Hopscotch JS Library, use one of the following:

self.create_hopscotch_tour ()


self.create_tour (theme="hopscotch")

Adding a step to a tour:

To add a tour step, use the following:

self.add_tour_step (message , css_selector, title, alignment, theme)

With theself.add_tour_step ()method, you must first pass a message to display. You can then specify a web element to attach to (by usingCSS selectors). If no element is specified, the tour step will tether to the top of the screen by default. You can also add an optional title above the message to display with the tour step, as well as change the theme for that step (Shepherd tours only), and even specify the alignment (which is the side of the element that you want the tour message to tether to).

Playing a tour:

You can play a tour by calling:

self.play_tour (interval

If you specify an interval (optional), the tour will automatically walk through each step after that many seconds have passed.

All methods have the optionalnameargument, which is only needed if you’re creating multiple tours at once. Then, when you’re adding a step or playing a tour, SeleniumBase knows which tour you’re referring too. You can avoid using thenamearg for multiple tours if you play a tour before creating a new one.

Here’s an example of using SeleniumBase Tours:

fromSeleniumbaseimportBaseCaseclassMyTourClass(BaseCase):     deftest_google_tour(self): (”         self.wait_for_element (” input [title=”Search”])         self.create_tourtheme=” (dark) “)         self.add_tour_step (Welcome to Google!,title=SeleniumBase Tours)         self.add_tour_step (Type in your query here.,input [title=”Search”])         self.play_tour ()         self.highlight_update_text (” input [title=”Search”],Google)         self.wait_for_element (” [role=”listbox”])#Wait for autocomplete        self.create_tourtheme=” (light) “)         self.add_tour_step (Then click to search.,[value=”Google Search”])         self.add_tour_step (Or press [ENTER] after entry.,[title=”Search”])         self.play_tour ()

This example was taken, which you can run from theexamples / tour_examplesfolder with the following command:

Exporting a Tour:

If you want to save the tour you created as a JavaScript file, use:

self.export_tour ()


self.export_tour (name=None, filename="my_tour.js")

(nameis optional unless you gave custom names to your tours when you created them.filenameis the name of the file to save the JavaScript to.) Once you’ve exported your tour, you can use it outside of SeleniumBase. You can even copy the tour’s JavaScript code to the Console of your web browser to play the tour from there (you need to be on the correct web page for it to work).

Brave Browser
Read More

About admin

Leave a Reply

Your email address will not be published. Required fields are marked *