Steps to start a Chromium program with the help of Chromedriver

Can I adapt this python code to work with Robot Framework?

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.action_chains import ActionChains

chrome_options = Options()
chrome_options.binary_location = 'C:/Program Files (x86)/MyApp.exe'
driver = webdriver.Chrome('C:/Program Files (x86)/chromedriver.exe', chrome_options=chrome_options)

I am attempting to set up a Chrome webdriver in Robot Framework that can communicate with my Chromium application. Is it feasible?

I have created a Python Library as shown in the code below, but it only opens my app and then closes it. I want to be able to execute Selenium/Robot calls with it.

Code for myLibrary.py

import selenium
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.action_chains import ActionChains

from robot.libraries.BuiltIn import BuiltIn

def pas_webdriver_instance():
    se2lib = BuiltIn().get_library_instance('ExtendedSelenium2Library')
    chrome_options = Options()
    chrome_options.binary_location = 'C:/Program Files (x86)/myapp.exe'
    driver = webdriver.Chrome('C:/Program Files (x86)/chromedriver.exe', chrome_options=chrome_options) 

Answer №1

If you want to customize your automation using Selenium2Library in Python, you have the option to either create a new class that extends the original library or access the running library's instance during runtime.

Alternatively, if you prefer to migrate this functionality to Robot Framework, you can experiment with the following keyword:

Open Chrome
    [Arguments]    ${url}    ${binary_path}
    ${chrome_options}=    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
    Call Method    ${chrome_options}    binary_location    ${binary_path}
    Create Webdriver    Chrome    chrome_options=${chrome_options}
    Go To    ${url}

Edit: In response to your query in the comments,

The method of customization may vary depending on the version of Selenium2Library being used. For versions pre-dating version 3, examples of expansion include accessing an instance here (refer to the property _s2l) and inheriting a class here (review the class declaration).

I have not delved into customizing the latest version of SeleniumLibrary yet, so I am unable to provide specifics for that scenario. However, retrieving the library's instance at runtime should continue to be effective.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Python 2.7's Timezone Adjustment

My current approach involves shifting a time forward or backward based on an integer value. I simply add or subtract the time shift from the hour, then use mod 24 when constructing the new time. time_structure = datetime.time((hour + time_zone_shift)%24, ...

Execute Selenium Grid - The process of uploading multiple files simultaneously to a webpage by using sendkeys

We are currently utilizing Selenium BDD scenarios on a Selenium Grid with Chrome browsers and Windows operating systems for the node machines. One of our scenarios involves uploading multiple files to a webpage. Here is the code I am using for remote execu ...

Send the data from a table to a Python method in Flask using AJAX

Recently, I picked up on flask and decided to create a small web tool for organizing data. The main page displays a table of list numbers and their respective descriptions. I managed to implement jQuery functionality that allows double clicking to select i ...

What is the process for running selenium-webdriver/protractor commands interactively within the command line of Chrome DevTools?

Guide on: creating a test without completion placing a breakpoint at the conclusion of the unfinished test navigating to repl / command line / chrome devtools running Selenium commands in repl / command line / chrome devtools ...

Utilizing a functional approach in Python to create a histogram with a time complexity of O

Is there a better way to phrase this question? Please feel free to correct me. If I wanted to create a histogram using functional programming in Python without any external libraries, how would it be done? def add_value(bins, x): i = int(x // 10) ...

Generating a NumPy array from a list using operations

I retrieved data from an SQLite database stored in a Python list with the following structure: # Here is an example data = [(1, '12345', 1, 0, None), (1, '34567', 1, 1, None)] My goal is to convert this list of tuples into a 2D NumPy a ...

Crack Captcha using Python

Currently, I am utilizing an Anti-Captcha Service in an attempt to bypass Google's ReCAPTCHA. The outcome of the code snippet is as follows: {'errorId': 0, 'status': 'ready', 'solution': {'gRecaptchaRespo ...

Django serving up a blend of HTML templates and JSON responses

Is there a way to render a template in Django and also return a JsonResponse in a single function? return render(request, 'exam_partial_comment.html', {'comments': comments, 'exam_id': exam}) I am attempting to combine this ...

Converting a source-target-weight dataframe into a JSON file

I have these three dataframes - source, target, and weight : source target weight 0 A B 3 1 A C 2 2 B C 0 3 C D 1 4 D ...

Is it possible to pass values using sendkeys in Selenium in order to select an item from a Bootstrap dropdown menu?

Is there a way to pass values for a bootstrap drop down menu using Selenium instead of selecting them? Can we use sendKeys in Selenium to achieve this? I need to input values CSS, HTML, JavaScript without manually selecting them during automation. <d ...

Using a Python loop to find the sum of numbers between two randomly generated values within the range of 1 to

Can someone assist me in creating a loop to generate two random integers between 1-10 and then calculate their sum within the range? import random total_sum = 0 from random import randrange num1 = (randrange(1,11)) num2 = (randrange(1,11)) count = tota ...

Attempting to implement a loop to remove specific characters

for num in range(0,len(input_user)): if input_user[num] == ('-'): if (input_user[num - 1].isalpha() and input_user[num + 1].isalpha()): goal += input_user[num] else: ...

Python requests no longer retrieves HTML content

I am trying to extract a name from a public Linkedin URL using Python requests (2.7). Previously, the code was functioning correctly. import requests from bs4 import BeautifulSoup url = "https://www.linkedin.com/in/linustorvalds" html = requests.get(url ...

Steps to remove the smallest number from an array: if there are multiple smallest numbers, remove the first one

I am currently working on a script that takes an array of random numbers as input. I have successfully implemented code to remove the lowest number in the array, but I'm facing an issue when there are multiple occurrences of this number. How can I ens ...

Gather information that is dynamic upon the selection of a "li" option using Python Selenium

I need to extract data from this website (disregard the Hebrew text). To begin, I must choose one of the options from the initial dropdown menu below: https://i.stack.imgur.com/qvIyN.png Next, click the designated button: https://i.stack.imgur.com/THb ...

Managing Unexpected Pop-Up Windows with Selenium

Our platform has a unique feature where customer feedback is collected. To ensure user engagement, a random window pops up when the user logs out, although not every time for each customer. I am looking to address this scenario in my automation code. Cur ...

What is the best way to annotate specific portions of the cumulative total in matplotlib?

I am working on creating a basic histogram using matplotlib in Python. The histogram will display the distribution of comment lengths based on several thousand comments. Here is the code I have so far: x = [60, 55, 2, 30, ..., 190] plt.hist(x, bins=100) ...

Using Python to display print statements and handle JSON responses

I am a beginner in Python and recently looked at the Python documentation, where I found information about the print statement that is similar to C language's printf. However, when I tried to implement it, I encountered some issues. Currently, I am wo ...

Utilize a DataFrame with a MultiIndex structure to index rows and columns using values from another DataFrame that includes row and column indices

Within my dataset, I have a collection of particle pairs identified by a unique combination of chain-index and intra-chain-index for each particle. Storing this information in a DataFrame named index_array, I now aim to create a matrix representation of al ...

Tips for executing a Python function from JavaScript, receiving input from an HTML text box

Currently, I am facing an issue with passing input from an HTML text box to a JavaScript variable. Once the input is stored in the JavaScript variable, it needs to be passed to a Python function for execution. Can someone provide assistance with this pro ...