Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98268

Can someone help me identify the issue with my auto login script?

$
0
0

I'm using python to automatically open a web page of an industrial camera to try to log into it for viewing. I found the example code online, but I can't get it to work for some unknown reason. Here is the python code:

import timefrom selenium import webdriver# import yaml# conf = yaml.load(open('loginDetails.yml'))# myLogin = conf['camera_user']['username']# myPassword = conf['camera_user']['password']myLogin = "operator"myPassword = ""driver = webdriver.Chrome()def login(url,usernameId, username, passwordId, password, submit_buttonId):   driver.get(url)   driver.find_element(usernameId).send_keys(username)   driver.find_element(passwordId).send_keys(password)   driver.find_element(submit_buttonId).click()login("http://192.168.0.60/pages/hmi/", "dc608255-0d87-4f6e-9115-62d8621f104c", myLogin, "03b9beea-df2a-4738-a3a9-d2d4ec1c5517", myPassword, "75ec946e-6c5d-4e6c-8429-75161a1cc83b")

It does open chrome and navigates to the page as expected, but after the delay it just closes the window. Here is also the stack trace from trying to run it:

        (No symbol) [0x00007FF60309BA4C]        (No symbol) [0x00007FF60307B983]        (No symbol) [0x00007FF603047628]        (No symbol) [0x00007FF603048791]        GetHandleVerifier [0x00007FF6034EA00D+3161901]        GetHandleVerifier [0x00007FF60353E060+3506048]        GetHandleVerifier [0x00007FF60353400D+3465005]        GetHandleVerifier [0x00007FF6032B0EEB+830987]        (No symbol) [0x00007FF60316467F]        (No symbol) [0x00007FF6031609D4]        (No symbol) [0x00007FF603160B6D]        (No symbol) [0x00007FF603150149]        BaseThreadInitThunk [0x00007FFE53BB7374+20]        RtlUserThreadStart [0x00007FFE5483CC91+33]PS C:\Users\pjw56q> & C:/Users/pjw56q/AppData/Local/Programs/Python/Python311/python.exe d:/cameralogin/WebsitesLoginAutomation.pyDevTools listening on ws://127.0.0.1:49281/devtools/browser/5c9bc2ed-a98a-43e6-99fe-e2fb16d04ee9Traceback (most recent call last):  File "d:\cameralogin\WebsitesLoginAutomation.py", line 21, in <module>    login("http://192.168.0.60/pages/hmi/", "UserTextBox", myLogin, "PasswordTextBox", myPassword, "LoginButton")  File "d:\cameralogin\WebsitesLoginAutomation.py", line 17, in login    driver.find_element(usernameId).send_keys(username)    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\pjw56q\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 766, in find_element    return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Users\pjw56q\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 380, in execute    self.error_handler.check_response(response)  File "C:\Users\pjw56q\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response    raise exception_class(message, screen, stacktrace)selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: invalid locator  (Session info: chrome=130.0.6723.70)Stacktrace:        GetHandleVerifier [0x00007FF6034C38A5+3004357]        (No symbol) [0x00007FF603159970]        (No symbol) [0x00007FF60300582A]        (No symbol) [0x00007FF603055945]        (No symbol) [0x00007FF603055E7C]        (No symbol) [0x00007FF60309EC27]        (No symbol) [0x00007FF60307BC1F]        (No symbol) [0x00007FF60309BA4C]        (No symbol) [0x00007FF60307B983]        (No symbol) [0x00007FF603047628]        (No symbol) [0x00007FF603048791]        GetHandleVerifier [0x00007FF6034EA00D+3161901]        GetHandleVerifier [0x00007FF60353E060+3506048]        GetHandleVerifier [0x00007FF60353400D+3465005]        GetHandleVerifier [0x00007FF6032B0EEB+830987]        (No symbol) [0x00007FF60316467F]        (No symbol) [0x00007FF6031609D4]        (No symbol) [0x00007FF603160B6D]        (No symbol) [0x00007FF603150149]        BaseThreadInitThunk [0x00007FFE53BB7374+20]        RtlUserThreadStart [0x00007FFE5483CC91+33]

I tried using different elements from the html for the three items I'm looking for, but that didn't work either. What's in the code above are the ids of the items, but I also tried using just their name.


Viewing all articles
Browse latest Browse all 98268

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>