Reputation:
I'm using the below python script to login to Fedex tracking service
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from time import sleep
driver = webdriver.Firefox()
driver.get("https://www.fedex.com/apps/fedextracking/?cntry_code=us&locale=us_en#")
sleep(5)
users = driver.find_element_by_xpath("//div[@class='fxg-field'][1]/input[@class='fxg-field__input-text']")
users.send_keys('test')
passwords = driver.find_element_by_xpath("//input[@id='pswd-input']")
passwords.send_keys('test')
sleep(3)
submit = driver.find_element_by_xpath("//button[@id='login']")
submit.click()
It is not showing exact error but showing these errors:
File "test.py", line 10, in <module>
users = driver.find_element_by_xpath("//div[@class='fxg-field'][1]/input[@class='fxg-field__input-text']")
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 393, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 966, in find_element 'value': value})['value']
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 318, in execute
response = self.command_executor.execute(driver_command, params)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 472, in execute
return self._request(command_info[0], url, body=data)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 495, in _request
self._conn.request(method, parsed_url.path, body, headers)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\http\client.py", line 1083, in request
self._send_request(method, url, body, headers)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\http\client.py", line 1128, in _send_request
self.endheaders(body)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\http\client.py", line 1079, in endheaders
self._send_output(message_body)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\http\client.py", line 913, in _send_output
self.send(message_body)
File "C:\Users\Home\AppData\Local\Programs\Python\Python35\lib\http\client.py", line 885, in send
self.sock.sendall(data)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
It works smoothly on Google Chrome but not working with Firefox. Please help me fix this issue.
EDIT
Firefox version 57.0.4 (64-bit)
Selenium version 3.13.0
geckodriver 0.21.0
UPDATE
The problem is with this website only. I tried other tracking site and they all working with Firefox. This particular site is not working with Firefox.
Upvotes: 2
Views: 1913
Reputation: 193138
Your code block was near perfect. I took your own code and made couple of tweaks which includes inducing WebDriverWait before invoking send_keys()
on the USER ID field as follows:
Code Block:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Firefox(executable_path=r'C:\Utility\BrowserDrivers\geckodriver.exe')
driver.get("https://www.fedex.com/apps/fedextracking/?cntry_code=us&locale=us_en#")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@class='fxg-field__input-text' and @name='USER']"))).send_keys('test')
driver.find_element_by_xpath("//input[@class='fxg-field__input-text' and @name='PASSWORD']").send_keys('test')
driver.find_element_by_xpath("//button[@class='fxg-button fxg-button--orange' and @name='login']/span").click()
Browser Snapshots:
USER ID
and PASSWORD
fields being filled up:Upvotes: 1
Reputation: 55
Inseted of using
driver.find_element_by_xpath("//div[@class='fxg-field'][1]/input[@class='fxg-field__input-text']")
try with
driver.find_element_by_xpath(//input[@name="USER"])
Upvotes: 0
Reputation: 531
It may be to do with your version of Firefox you're using. Check which Firefox browser versions are supported by selenium. https://www.seleniumhq.org/about/platforms.jsp.
Support for Firefox is the latest release, the previous release, the latest ESR release and the previous ESR release.
For example Selenium 2.40.0 (released on Feb 19, 2014) supports Firefox 27, 26, 24, 17
Selenium with Firefox can be run on any platform that Firefox supports for those versions, that also allow users to install a custom Firefox extension.
Upvotes: 0