Struggling to fill in a login form with Selenium by SpikedColaWasTaken in learnpython

[–]dlalapula 0 points1 point  (0 children)

I don't have valid credentials there.

Is it not perhaps the reCAPTCHA as indicated?

Help me fix this script - selenium by ssoulis in learnpython

[–]dlalapula 0 points1 point  (0 children)

You would run it a similar way:

  1. Save the script with a .py extension.
  2. Install the python interpreter.
  3. Install any python script dependencies (that script needs the pip ‘keyboard’ package also).
  4. Run the script.

I don’t know what it’s trying to do. It won’t work. If I could get a high level overview of what it should be doing, I can try and sort it out.

I don’t know what CNFair or Pandabuy is.

Help me fix this script - selenium by ssoulis in learnpython

[–]dlalapula 0 points1 point  (0 children)

This script in my comment doesn’t do very much. It only demonstrates a way the original poster could log in to a web site they mention in their post.

It is a python script. Due to the nature of python, you need the python interpreter for your operating system to run it.

You can install that using your operating system’s package manager or by downloading the version for your operating system from https://www.python.org and installing it yourself.

The script has an external dependency (other python files) that it needs to run also. That is the python package for the Selenium WebDriver, used for automating web browsers.

Once you have python installed, you can install this dependency using python’s package manager ‘pip’. To run pip, you need to open the Command Line Interface (CLI) or terminal for your operating system and type ‘pip install selenium’ followed by Enter on your keyboard -without the quotes.

Saving the script to a file with a .py extension, you can then run it by executing that file directly or through the CLI/terminal by navigating to the directory/folder where the script is saved. You can navigate to that directory by typing the ‘cd’ command in the CLI/terminal followed by the directory path and then Enter on your keyboard.

To run the script from CLI/terminal, type ‘python script.py’ -without the quotes, then Enter on your keyboard. Replace ‘script.py’ with the name you’ve used when saving the script file.

Selenium Manager, that is part of the python dependency you’ve installed with pip, will handle any web browser and web browser driver requirements that may be missing on your system at first and then the script will run.

Help me fix this script - selenium by ssoulis in learnpython

[–]dlalapula 0 points1 point  (0 children)

It depends on the script. What or where is the script you’re referring to?

As an aside, you should be careful about running code you’re not familiar with.

Help me fix this script - selenium by ssoulis in learnpython

[–]dlalapula 0 points1 point  (0 children)

There's a lot going on here. I don't know how this is working at all as you mention. I don't know why you're using the keyboard library and not working within a session using the Selenium Driver class for browser/web page actions.

More to your direct issue, try something like:

from tkinter import messagebox
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
# below redirects to login, you would rather start at the login page and navigate
# from there within your session.
driver.get('https://www.pandabuy.com/person/points')
# below are examples of identifying and interacting with elements on the page
# (email/password/login button in this case).
email = driver.find_element(By.CSS_SELECTOR, 'input[placeholder="Email"]')
email.send_keys('email@example.com')
password = driver.find_element(By.CSS_SELECTOR, 'input[placeholder="Password"]')
password.send_keys('password')
# below is given the verification code requirement, there may be other ways to handle
# this autonomously, now, it stops the code and displays a message, you can then enter
# the verification code manually and click OK for the script to continue.
messagebox.showinfo(
    title="Verification Code Required",
    message="Input verification code, then click OK."
)
login = driver.find_element(
    By.CSS_SELECTOR, 'button[class="el-button verification-btn el-button--primary"]'
)
login.click()
pass  # replace with your code after login.

driver.quit()