Executing a program using Selenium to gather information

Current Progress

I successfully developed a Python script that utilizes Selenium to open a Firefox browser and extract data to an excel file. Furthermore, I have converted this script into an executable file without encountering any errors thanks to Pyinstaller.

Challenges Faced

Unfortunately, when attempting to run the newly created executable on my work laptop, it fails to launch the browser or generate any output. Instead, a command window briefly appears before closing automatically.

My Objective

The purpose of this project is to streamline the process of data extraction for my colleagues by providing them with a user-friendly script. This eliminates the need to manually retrieve information from the website every time. Additionally, I aim to restrict their access to system settings and prevent multiple browsers from opening simultaneously.

Query

Could the lack of geckodriver path be hindering the execution of Firefox in the executable? Do I need to ensure the geckodriver presence on each PC where the script will be used?

Code Implementation

     from selenium import webdriver
     from selenium.webdriver.common.by import By
     from selenium.webdriver.support.ui import WebDriverWait
     import pandas as pd
     

     productName = []
     number = []
     divList = []

     driver = webdriver.Firefox()
     driver.get("website")

     radioBtn = driver.find_element_by_id("ContentPlaceHolder1_company")
     radioBtn.click()

            
     element = driver.find_element_by_id("ContentPlaceHolder1_TextBoxInput1")
     element.send_keys("CompanyName")

     
    Search = driver.find_element_by_id("ContentPlaceHolder1_view1Continue")
    Search.click()

   driver.implicitly_wait(10)

   driver.find_element_by_id("ctl00_ContentPlaceHolder1_92564").click()

    driver.implicitly_wait(2)

    divList = driver.find_elements_by_class_name('nopgbrk')

    for div in divList:
    number.append(div.find_element_by_xpath('a').text)
    productName.append(div.find_element_by_xpath('span').text)

    df = pd.DataFrame({'Product':productName, 'Registration': number})

    df.to_excel("C:\Python\Scrapeddata\Scrape.xls")

Answer №1

The reason why your official laptop is having issues could be due to the mismatch between the chromedriver version and the Chrome version.

During the development process, the system being used had a compatible version of Chrome with the selenium chromedriver, resulting in successful output processing. However, your official laptop's Chrome version does not match that of the system, causing compatibility issues.

To resolve this, check your Chrome version by navigating to settings -> About Chrome.

Download the appropriate chromedriver for the identified Chrome version from this link and create an executable file if supported: https://sites.google.com/a/chromium.org/chromedriver/downloads

If you are aware of the chromedriver version, it may be easiest to uninstall Chrome on your official laptop and install the same version that matches the chromedriver.

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

Managing Windows Authorization using Selenium WebDriver and Internet Explorer 10 - A Step-by-Step Guide

I am experiencing difficulties with Windows authentication while trying to create an automation test (in C#) using Selenium Webdriver with the InternetExplorer Driver. Although I can access https//username:[email protected] successfully through Firef ...

the process of combining individual strings from a variable into one cohesive list

I have encountered a challenge while trying to retrieve objects from a specific bucket with a given prefix. My goal is to only display the objects with the extension "*.xlsx". However, I am currently facing an issue at the following step: import boto3 s3 ...

Does Python implement pointers similar to c++? Discussing Python's approach to low-level implementation

Is it true that Python uses pointers for operations? I've also heard that every variable, such as integers and strings, is considered an object. Can someone explain the low-level implementation of variables in Python to me? I'm confused about wh ...

What is the best method for eliminating additional quotation marks from strings within a collection?

I've been developing a method to return a list in the format List[Tuple[Set[str], Set[str]]], but I'm struggling with removing extra quotes. The attribute self._history[dates[dat]]._ridings consists of a list of strings. This method aims to compa ...

How can you display Bokeh HTML visualizations on your WordPress site?

I've developed a Python Bokeh dashboard with visualizations and saved the HTML file. Viewing it in my browser displays the graphs as expected. However, I'm facing issues trying to showcase this dashboard on my WordPress site. Simply pasting the H ...

Refine the pandas Dataframe with a filter on a JavaScript-enabled website

I recently inherited a large software project using Python/Flask on the backend and HTML/Javascript on the frontend. I'm now looking to add some interactivity to one of the websites. I have successfully passed a dataframe to the webpage and can displa ...

How to submit form data with a POST request in Flask using fetch without having to reload

Despite reading numerous similar questions, I am still unable to determine how to achieve my goal. I have multiple forms on a single page and I am trying to submit data from each form without refreshing the page. Below is an example of one of the five form ...

Error: The element being referenced is no longer connected to the webpage, making it unable to be interacted with (Irrelevant to click action

Here lies the traceback code. 2021-10-04 18:21:53.294724 : ERROR : Message: stale element reference: element is not attached to the page document (Session info: chrome=93.0.4577.63) (Driver info: chromedriver=71.0.3578.80,platform=Linux 4.9.230-76 aarch64) ...

Appium encountered an error on iOS with the message: "NSCocoaErrorDomain Error Code 260: The file named 'WebDriverAgentRunner-Runner.app' cannot be opened as it does not exist"

While running appium on a real iPhone, I encountered the following error message. Despite searching for a solution, I have not been able to resolve it yet. [XCUITest] Using WDA path: '/Applications/Appium.app/Contents/Resources/app/node_modules/appiu ...

What causes the unrecognized command line error to occur while using distutils to build a C extension?

When attempting to construct a source using the python's distutils, I encountered an issue. I crafted a basic setup.py following guidance from this example, and executing the build as recommended resulted in success: python setup.py build Now, it is ...

Issues with Selenium getting stuck while using pyvirtualdisplay

Running Selenium with Python on a server requires the ability to hide the Chrome display. Most of the time, the Python script runs smoothly, but occasionally it gets stuck when creating a new chromedriver session. It's puzzling why this happens interm ...

python requests timeout isn't functioning as expected

Seeking to enhance my comprehension of the python request timeout, I decided to conduct a brief test. Based on my understanding, the timeout parameter is measured in seconds; hence, a timeout value of 1 signifies that if the connection or read time exceeds ...

Is it possible to run nightwatch.js tests on a Linux machine?

Struggling to kick off the nightwatch automated UI tests on a Linux machine running CentOS OS? Starting is proving to be quite challenging. This is the test_settings configuration in my nightwatch.json: "test_settings": { "default": { ...

How to terminate a Selenium "click" thread after a timeout

I have successfully implemented a method for terminating a Selenium get thread after a set timeout by following instructions I came across on Stack Overflow... String url = "https://www.myurl.me"; Integer timeout = 3000; Thread t = new Thread(new Runnable ...

Top-notch beginner-friendly tutorials for Selenium Python bindings

As someone new to the field of automation, I am eager to learn python selenium. However, I am struggling to find the most suitable tutorials for beginners that will provide me with comprehensive knowledge. If you have any recommendations for the top tutor ...

An error is triggered, resulting in a TypeError being raised

I have a question regarding try-except statements that is different from the other questions mentioned. I am not in need of a finally statement... Consider the following code snippet: try: #dosomething except TypeError: #dosomething -> THIS RE ...

Populate the text box with the bb code using Selenium in Python

I'm in the process of creating a test for the discussion board, and I want to experiment with the forum's BB code. Here is an example of the BB code I am working with: [B][FONT=Trebuchet MS][SIZE=7]Meteor[/SIZE][/FONT][/B] [COLOR=#000000][FONT=V ...

Python Script for Conducting a Google Search

Looking to develop a Python script that can take a user-entered question and fetch the answer using Google Custom Search API, Bing, or another search API. When attempting to use the Google Custom Search API, I encountered the following script: <script& ...

Azure Machine Learning dataset creation seems to be stuck in an endless loop

I'm facing an issue while attempting to generate a Dataset from a data store using Azure ML. The process seems to hang indefinitely without completion. Below is the code snippet I'm running, derived from Microsoft's documentation: import az ...

Need help fixing a corrupted JSON file that contains escaped single and double quotes?

Challenge I am faced with a sizable JSON file (~700,000 lines, 1.2GB in size) that contains Twitter data which needs preprocessing for both data and network analysis purposes. While collecting the data, an error occurred: instead of using " as a separator ...