0

Hi I'm trying to click a button using python in selenium for the page https://walmart.wd5.myworkdayjobs.com/login and I tried with both XPATH and ID used click, send_keys(Keys.enter), submit but still is not clicking. Can anyone help me please?

options = Options()
options.add_experimental_option('excludeSwitches', ['enable-logging'])

driver = webdriver.Chrome(executable_path=r"C:\Users\user\Downloads\chromedriver_win32 (1)\chromedriver.exe,chrome_options=options")
# Load webpage
driver.get(url)
driver.maximize_window() # For maximizing window
driver.implicitly_wait(20) # gives an implicit wait for 20 seconds
# Find first name field and fill it out
email = driver.find_element(By.XPATH,"//*[@id='input-4']").send_keys("1234@gmail.com");
passw = driver.find_element(By.XPATH,"//*[@id='input-5']").send_keys("1233@1102");
sub = driver.find_element(By.XPATH,"//*[@id='input-5']").send_keys(Keys.TAB + Keys.ENTER)
Ajeet Verma
  • 2,938
  • 3
  • 13
  • 24
Yashwanth
  • 17
  • 1
  • 6
  • Please give more clarifications when you ask something here : what errors do you encounter ? Could you show some code ? Have you tried to print the visible elems to the console, to check if selenium detects the element in the first place ? – l -_- l May 04 '23 at 19:29
  • I'm getting an error saying " USB: usb_device_handle_win.cc:1046 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)". – Yashwanth May 04 '23 at 20:01
  • Do any of [these answers](https://stackoverflow.com/questions/64927909/failed-to-read-descriptor-from-node-connection-a-device-attached-to-the-system) help you ? – l -_- l May 04 '23 at 20:06
  • Nope I tried all – Yashwanth May 04 '23 at 20:08
  • Could you edit your question to add an [MRE](https://stackoverflow.com/help/minimal-reproducible-example) ? – l -_- l May 04 '23 at 20:10
  • The code should work fine, your link is incorrect tho (404 page) – l -_- l May 04 '23 at 22:27

1 Answers1

0

First of all, the correct URL to log in on the above-mentioned portal is: https://walmart.wd5.myworkdayjobs.com/en-US/WalmartExternal/login

Now, you're right, it doesn't let us log in simply by clicking on the Sign In button when we try to do an automation login using Selenium or I would say any other automation tool.

I have noticed that it does perform the click when we try to apply click() on the Sign In button but nothing happens afterward.

My friend, after many hit and trail using different things, I'm able to bring you the solution.

Here is the solution:

import time
from selenium.webdriver import Chrome, ChromeOptions
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
import selenium.webdriver.support.expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains

options = ChromeOptions()
options.add_argument('--start-maximized')
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_argument("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36")


driver = Chrome(options=options)
wait = WebDriverWait(driver, 10)

url = "https://walmart.wd5.myworkdayjobs.com/en-US/WalmartExternal/login"
driver.get(url)

wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, 'input[data-automation-id="email"]')))
email = driver.find_element(By.CSS_SELECTOR, 'input[data-automation-id="email"]')
email.send_keys('your_username')

password = driver.find_element(By.CSS_SELECTOR, 'input[data-automation-id="password"]')
password.send_keys('your_password')

submit = driver.find_element(By.CSS_SELECTOR, 'div[aria-label="Sign In"]')

hover = ActionChains(driver).move_to_element(submit)
hover.click().perform()

time.sleep(10)

Few things to note:

  1. The correct URL to log in is https://walmart.wd5.myworkdayjobs.com/en-US/WalmartExternal/login
  2. we need to wait for the Sign In box to appear on the page.
  3. we must pass the user-agent to the Chrome options.
  4. Use ActionChains to successfully perform the click to get to the logged-in profile. A simple click() will not work here.

I hope it solves your problem. Cheers!

Ajeet Verma
  • 2,938
  • 3
  • 13
  • 24