1

I am currently using Walmart's job site and I'm trying to log in using Selenium with python. So far I am using the following code:

from selenium import webdriver
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoSuchWindowException
from selenium.common.exceptions import WebDriverException
import argparse
import time
import traceback
import sys

while True:
        try:

            func_name = driver.find_element_by_id('extension_4').get_attribute('onkeyup')
            func_name = func_name[func_name.index(':')+1:]
            num = driver.execute_script('return ' + func_name)

            #js_functions.append(num)

            print repr(num)

        except NoSuchElementException: 
            exc_info = sys.exc_info()
            traceback.print_exc()

        except NoSuchWindowException:  # No Need to Continue if User closes Window
            break;

        try:
            driver.execute_script('return username(arguments[0])', '[email protected]')
        except WebDriverException:
            exc_info = sys.exc_info()
            traceback.print_exc()
        
        time.sleep(2)

When I print num from this line:

 num = driver.execute_script('return ' + func_name).

It prints the username and password. I then try to update the function given (for example username) with the following line:

driver.execute_script('return username(arguments[0])', '[email protected]')

it complains that there is no such function what am I doing wrong? I've been stuck on this for a few weeks now any guidance or solutions will really help me.

0

1 Answer 1

2

Unless you have a particular reason to use JS, selenium can do this for you:

driver.find_element_by_id('username').send_keys(username_variable)
driver.find_element_by_id('password').send_keys(password_variable)
driver.find_element_by_id('event-submit').click()

Did you have some other issue?

Sign up to request clarification or add additional context in comments.

1 Comment

This doesn't work. The reason why I mentioned JS is because it looks like those form variables are in javascript when I look at the source code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.