Головоломка с каркасом робота, прокрутите в поле зрения. Я не могу получить слайдер веб -элемента, чтобы начать прокручиPython

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Головоломка с каркасом робота, прокрутите в поле зрения. Я не могу получить слайдер веб -элемента, чтобы начать прокручи

Сообщение Anonymous »

Профиль LTL на Stackoverflow сделал отличную попытку сделать полосу препятствий Tosca, но затем сделано с помощью Robot Framework (настоящий умный, чтобы тренировать тестирование автоматизации, и вы можете сравнить) < /p>
, если Вы новичок с автоматизацией тестов, это действительно хороший способ начать. Это действительно хорошая помощь для сообщества. Включая красивую чтлу.
Но мне нужна помощь сообщества, потому что я застрял с одной из головоломок. Как это сделать с Tosca, действительно просто и просто. (3 -е видео) < /p>
То, что я имею, состоит из 2 частей ... < /p>
Код пользовательского библиотеки, который я сделал для этого (имя файла - это CustomActionsInteGrated.py ) < /p>
from robot.api.deco import keyword

@keyword('Draw Dot and Click At Coordinates') # New combined keyword
def draw_and_click_at_coordinates(x, y):
"""
Draw a red dot at the specified coordinates (x, y) for debugging purposes,
then simulate a click event at the same coordinates, followed by holding the LEFT mouse button,
scrolling down with the mouse wheel, and moving the mouse down simultaneously.
"""
# JavaScript to draw the red dot
draw_script = f"""
var marker = document.createElement('div');
marker.style.position = 'absolute';
marker.style.left = '{x}px';
marker.style.top = '{y}px';
marker.style.width = '20px';
marker.style.height = '20px';
marker.style.backgroundColor = 'blue';
marker.style.borderRadius = '50%';
marker.style.zIndex = '9999';
marker.style.pointerEvents = 'none';
marker.style.border = '2px solid black';
document.body.appendChild(marker);
"""

# JavaScript to simulate the click
click_script = f"""
var event = new MouseEvent('click', {{ clientX: {x}, clientY: {y}, bubbles: true, cancelable: true }});
document.elementFromPoint({x}, {y}).dispatchEvent(event);
"""

# JavaScript to simulate LEFT mouse button down
mouse_down_script = f"""
var mouseDownEvent = new MouseEvent('mousedown', {{
clientX: {x},
clientY: {y},
button: 0, // 0 = LEFT mouse button
bubbles: true,
cancelable: true
}});
document.elementFromPoint({x}, {y}).dispatchEvent(mouseDownEvent);
"""

# JavaScript to simulate mouse wheel scroll down (page down)
wheel_scroll_script = f"""
var wheelEvent = new WheelEvent('wheel', {{
deltaY: 1000, // Positive value scrolls down
clientX: {x},
clientY: {y},
bubbles: true
}});
document.elementFromPoint({x}, {y}).dispatchEvent(wheelEvent);
"""

# JavaScript to simulate mouse movement down
mouse_move_script = f"""
var mouseMoveEvent = new MouseEvent('mousemove', {{
clientX: {x},
clientY: {y + 1000}, // Move 1000 pixels down
bubbles: true,
cancelable: true
}});
document.elementFromPoint({x}, {y}).dispatchEvent(mouseMoveEvent);
"""

# JavaScript to simulate LEFT mouse button up
mouse_up_script = f"""
var mouseUpEvent = new MouseEvent('mouseup', {{
clientX: {x},
clientY: {y + 1}, // Release at the new position
button: 0, // 0 = LEFT mouse button
bubbles: true,
cancelable: true
}});
document.elementFromPoint({x}, {y +1}).dispatchEvent(mouseUpEvent);
"""

# Combine all actions with minimal delays
return f"""
{draw_script}
setTimeout(function() {{
{click_script}
setTimeout(function() {{
{mouse_down_script}
setTimeout(function() {{
{wheel_scroll_script}
{mouse_move_script}
setTimeout(function() {{
{mouse_up_script}
}}, 50); // Delay after combined actions before releasing mouse button
}}, 10); // Minimal delay after mouse down before combined actions
}}, 10); // Minimal delay after click before mouse down
}}, 10); // Minimal delay after drawing before click
"""
< /code>
и файл .robot это: < /p>
*** Settings ***
Library SeleniumLibrary
Library CustomAction1.py # Import the custom actions file
Library CustomAction2.py # Import the custom actions file
Library CustomActionsIntegrated.py
Variables variables.py

*** Variables ***
${URL} https://obstaclecourse.tricentis.com/Obstacles/99999

*** Test Cases ***
Visueel Klikken Onder Submit
Open Browser ${URL} Chrome
Maximize Browser Window
Wait Until Element Is Visible xpath=//*[@id='submit']

# Get element's position using JavaScript
${location}= Execute JavaScript
... var rect = document.evaluate("//*[@id='submit']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.getBoundingClientRect();
... return [rect.left + (rect.width / 2) + 132, rect.top + window.scrollY + 130];

# Access the location array using indexes for x and y
${click_x}= Set Variable ${location}[0]
${click_y}= Set Variable ${location}[1]

# Scroll to make the click area visible
Execute JavaScript window.scrollTo(0, ${click_y} - 200);
#Sleep 1s

# Draw the red dot using the custom keyword
Draw Red Dot ${click_x} ${click_y}
#Sleep 1s

# Click the page at the specified coordinates using the custom keyword
#Click Page At Coordinates ${click_x} ${click_y}
#Sleep 1s

#combined , blue dot
${js_code}= Draw Dot and Click At Coordinates ${click_x} ${click_y}
Execute JavaScript ${js_code}

#Draw Dot and Click At Coordinates ${click_x} ${click_y}
#Draw Dot and Click At Coordinates ${click_x} ${click_y}

# Wait for the page to respond before proceeding

# Click at the exact location (Now with improved visibility)
#Click Element At Coordinates xpath=//*[@id='submit'] 132 130

# Wait for the page to respond before proceeding

# Scroll down to bring up more content (if required)
#Press Keys //body PAGE_DOWN
Sleep 2s

# Ensure overlay2 is visible (if needed)
#Execute JavaScript document.getElementById('textfield').scrollIntoView()

# Input text in the text field
Input Text xpath=//*[@id='textfield'] Tosca
Sleep 1s

# Drag overlay2 down
#Drag And Drop By Offset id=overlay2 0 100
Sleep 2s

# Click the submit button again
Click Element xpath=//*[@id='submit']

# Validate success message
Element Should Contain xpath=//body You solved this automation problem.
< /code>
Но я не могу заставить его работать. Может быть, я думаю о том, чтобы сложно. Я попробовал помощь DeepSeek и CHATGPT, но я еще не нашел правильного рабочего решения. < /P>
Так что, если вы видите какие -либо ошибки или видите решение. Пожалуйста, помогите. также.

Подробнее здесь: https://stackoverflow.com/questions/794 ... of-a-web-e
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • Прокрутите до элемента, только если его нет в поле зрения – jQuery
    Anonymous » » в форуме Jquery
    0 Ответы
    16 Просмотры
    Последнее сообщение Anonymous
  • SQLразработчикамфруктовая головоломка
    Anonymous » » в форуме Python
    0 Ответы
    13 Просмотры
    Последнее сообщение Anonymous
  • SQLразработчикамфруктовая головоломка
    Anonymous » » в форуме Python
    0 Ответы
    20 Просмотры
    Последнее сообщение Anonymous
  • Головоломка «Испытание дронов»
    Anonymous » » в форуме JAVA
    0 Ответы
    12 Просмотры
    Последнее сообщение Anonymous
  • C ++ головоломка для тех, кто заинтересован [закрыт]
    Anonymous » » в форуме C++
    0 Ответы
    1 Просмотры
    Последнее сообщение Anonymous

Вернуться в «Python»