@world.absorb
def create_component_instance(step, category, component_type=None, is_advanced=False, advanced_component=None):
 assert_in(category, ['advanced', 'problem', 'html', 'video', 'discussion'])
 component_button_css = 'span.large-{}-icon'.format(category.lower())
 if (category == 'problem'):
  module_css = 'div.xmodule_CapaModule'
 elif (category == 'advanced'):
  module_css = 'div.xmodule_{}Module'.format(advanced_component.title())
 elif (category == 'discussion'):
  module_css = 'div.xblock-author_view-{}'.format(category.lower())
 else:
  module_css = 'div.xmodule_{}Module'.format(category.title())
 module_count_before = len(world.browser.find_by_css(module_css))
 world.disable_jquery_animations()
 world.css_click(component_button_css)
 if (category in ('problem', 'html', 'advanced')):
  world.wait_for_invisible(component_button_css)
  click_component_from_menu(category, component_type, is_advanced)
 expected_count = (module_count_before + 1)
 world.wait_for((lambda _: (len(world.css_find(module_css)) == expected_count)), timeout=20)

@ world . absorb def create_component_instance ( step , category , component_type = None , is_advanced = False , advanced_component = None ) : assert_in ( category , [ 'advanced' , 'problem' , 'html' , 'video' , 'discussion' ] ) component_button_css = 'span.large-{}-icon' . format ( category . lower ( ) ) if ( category == 'problem' ) : module_css = 'div.xmodule_CapaModule' elif ( category == 'advanced' ) : module_css = 'div.xmodule_{}Module' . format ( advanced_component . title ( ) ) elif ( category == 'discussion' ) : module_css = 'div.xblock-author_view-{}' . format ( category . lower ( ) ) else : module_css = 'div.xmodule_{}Module' . format ( category . title ( ) ) module_count_before = len ( world . browser . find_by_css ( module_css ) ) world . disable_jquery_animations ( ) world . css_click ( component_button_css ) if ( category in ( 'problem' , 'html' , 'advanced' ) ) : world . wait_for_invisible ( component_button_css ) click_component_from_menu ( category , component_type , is_advanced ) expected_count = ( module_count_before + 1 ) world . wait_for ( ( lambda _ : ( len ( world . css_find ( module_css ) ) == expected_count ) ) , timeout = 20 )
create a new component in a unit .