<file_sep>import os

from allure_commons._allure import attach
from allure_commons.types import AttachmentType
from selenium import webdriver
from pages.drag_drop import drag_drop


def before_scenario(context,scenario):
    dir = os.getcwd()
    option=webdriver.ChromeOptions()
    #option.add_argument("--start-maximized")
    option.add_argument("headless")
    config_file = "\config_files\chromedriver.exe"
    context.browser = webdriver.Chrome(executable_path=dir + config_file, chrome_options=option)
    #context.browser = webdriver.Chrome(executable_path=dir + config_file)
    context.dd=drag_drop(context.browser)

def after_scenario(context,scenario):
    context.browser.quit()
def after_step(context,step):
    if step.status == "failed":
        context.browser.save_screenshot('c://b/screenshot.png')
        attach(
            context.browser.get_screenshot_as_png(),
            name="Screenshot",
            attachment_type=AttachmentType.PNG)
<file_sep>from behave import when,then
from numpy.testing import assert_equal

expected_result="100"

@when(u'He drags the slide to the end')
def step_impl(context):

    context.dd.slide()

@then(u'he sees the 100 value')
def step_impl(context):
    v = context.dd.msg_slide()
    assert_equal(v, expected_result)<file_sep>behave==1.2.6
numpy==1.19.5
selenium==3.141.0
<file_sep>from selenium.webdriver import ActionChains

from Browser import Browser

source_id = "draggable"
x_box_offset = 141
y_box_offset = 41
msg_id = "dropText"
slide = '/html[1]/body[1]/form[1]/fieldset[1]/div[1]/div[5]/input[1]'
x_slide_offset = 280
y_slide_offset = 16
value_id = "range"


class drag_drop(Browser):

    def setup(self, link):
        self.driver.get(link)

    def drag(self):
        source = self.driver.find_element_by_id(source_id)
        action = ActionChains(self.driver)
        action.drag_and_drop_by_offset(source, x_box_offset, y_box_offset).perform()

    def slide(self):
        slider = self.driver.find_element_by_xpath(slide)
        action = ActionChains(self.driver)
        action.drag_and_drop_by_offset(slider, x_slide_offset, y_slide_offset).perform()

    def msg_box(self):
        m = self.driver.find_element_by_id(msg_id).text
        return m

    def msg_slide(self):
        v = self.driver.find_element_by_id(value_id).text
        return v<file_sep>from behave import given,when,then
from numpy.testing import assert_equal

url="https://qavbox.github.io/demo/dragndrop/"
expected_result="Dropped!"

@given(u'The user is on the dragadrop home page')
def step_impl(context):
    context.dd.setup(url)

@when(u'He drags the box to the target under "drop here" message')
def step_impl(context):
    context.dd.drag()

@then(u'The user should see the message "dropped !"')
def step_impl(context):
        msg=context.dd.msg_box()
        assert_equal(msg,expected_result)