Why doesn't Selenium's response have a sessionId? - python

I'm trying to run Selenium's Firefox webdriver and am getting the error below. I can see that the response does not have a sessionId - the offending line is self.session_id = response['sessionId'] - but I don't know why. I've run this in the following ways and get the same error:
Cygwin, running nosetests
Cygwin directly
Windows, running nosetests
Windows directly
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\dev\tools\cygwin\home\207013288\dev\projects\scorpion\test\unit\test_
approve_workflows.py", line 27, in test_login
'password', userid='207013288', test=True)
File "C:\dev\tools\cygwin\home\207013288\dev\projects\scorpion\src\workflows.p
y", line 20, in login
browser = webdriver.Firefox()
File "C:\dev\sdks\Python33\lib\site-packages\selenium-2.32.0-py3.3.egg\seleniu
m\webdriver\firefox\webdriver.py", line 62, in __init__
desired_capabilities=capabilities)
File "C:\dev\sdks\Python33\lib\site-packages\selenium-2.32.0-py3.3.egg\seleniu
m\webdriver\remote\webdriver.py", line 72, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\dev\sdks\Python33\lib\site-packages\selenium-2.32.0-py3.3.egg\seleniu
m\webdriver\remote\webdriver.py", line 116, in start_session
self.session_id = response['sessionId']
nose.proxy.KeyError: 'sessionId'
-------------------- >> begin captured logging << --------------------
selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:63801/
hub/session {"sessionId": null, "desiredCapabilities": {"version": "", "browserN
ame": "firefox", "platform": "ANY", "javascriptEnabled": true}}
--------------------- >> end captured logging << ---------------------
I haven't used Selenium before and I'm not sure where to go from here.

OK, first of all I'd like to say that I nearly pulled out all my hair trying to fix this.
My setup:
Python 2.7
Firefox 22.0
Selenium WebDriver 2.33
Windows XP (internet connection via proxy server)
Spotted my problem yet?
Solution:
Open the control Panel
Internet options
Connections
LAN Configuration
On this page you will probably see the details of your proxy server, complete with a checkbox: "Do not use proxy server for local addresses".
This checkbox is probably already selected (as it makes good sense to not use a proxy for local addresses).
Unfortunately, Selenium WebDriver appears to ignore this checkbox and it's value.
Checked or unchecked, it will detect your proxy server and apply it to all url's (or at least that's what it did in my case.)
Click the "Advanced" button, and manually enter "127.0.0.1" in the "Exceptions" box.
Save the change.
Re-run your test in web driver, hopefully you will no longer see error message that refers to: self.session_id = response['sessionId']
Things that didn't work for me:
Before finding this solution (with the aid of a more experienced engineer) I went through the instructions here:http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp#advanceduserinteractions
.. for setting/changing/bypassing the proxy. Didn't get me the result I was looking for, though.
I also looked at this:
Implementing WebdriverBackedSelenium in Python
.. but it speaks of a older version of webdriver, and it suggests removing all the proxy settings system wide, which is an absolute non-starter (as far as I'm concerned).

MAC OSX SOLUTION
I'm using Python 2.7 and FireFox 48.0.2 and Chrome Versie 57.0.2987.98 (64-bit).
The error *self.session_id = response['sessionId']* for me was solved by going to System preferences -> Network -> Advanced in the Wifi Tab. -> Proxy's -> Turning "Automatic Proxydetection" on.
After changing this, the error no longer occurred.

Related

Can't initialize ANT+ Node with Python OpenANT library

I've totally new in Python and also in the ANT+ technology. I wonder if that's not some basic problem, but I've been strugling with it for couple of days already browsing through forums with no luck..
So I'm trying to use the Python OpenANT library (https://github.com/Tigge/openant) to access my ANT doungle which is plugged into the USB port (WINDOWS 10 PRO). My goal is to access my Garmin through it and get some data from it. However, I'm stuck at the very beginning trying to inizialize the ANT Node. My code is this:
from ant.easy.node import Node
node=Node()
To this I get the exception:
File "C:/Users/Edgars/Desktop/untitled-5.py", line 2, in <module>
pass
File "C:\Users\Edgars\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\ant\easy\node.py", line 56, in __init__
self.ant = Ant()
File "C:\Users\Edgars\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\ant\base\ant.py", line 68, in __init__
self._driver.open()
File "C:\Users\Edgars\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\ant\base\driver.py", line 193, in open
cfg = dev.get_active_configuration()
File "C:\Users\Edgars\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyusb-1.1.0-py3.8.egg\usb\core.py", line 909, in get_active_configuration
return self._ctx.get_active_configuration(self)
File "C:\Users\Edgars\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyusb-1.1.0-py3.8.egg\usb\core.py", line 113, in wrapper
return f(self, *args, **kwargs)
File "C:\Users\Edgars\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyusb-1.1.0-py3.8.egg\usb\core.py", line 250, in get_active_configuration
bConfigurationValue=self.backend.get_configuration(self.handle)
File "C:\Users\Edgars\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyusb-1.1.0-py3.8.egg\usb\backend\libusb0.py", line 519, in get_configuration
ret = self.ctrl_transfer(
File "C:\Users\Edgars\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyusb-1.1.0-py3.8.egg\usb\backend\libusb0.py", line 601, in ctrl_transfer
return _check(_lib.usb_control_msg(
File "C:\Users\Edgars\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyusb-1.1.0-py3.8.egg\usb\backend\libusb0.py", line 447, in _check
raise USBError(errmsg, ret)
usb.core.USBError: [Errno None] b'libusb0-dll:err [control_msg] sending control message failed, win error: A device which does not exist was specified.\r\n\n'
I have closed the Garmin Agent, so no other programs are using my ANT dongle at the same time. When I run my code, the specific sound occurs every time - the one that we hear when we detach a USB device by selecting "Eject" from the drop-down menu (the sound happens simultaneously with the exception message), so I guess the USB gets accessed at some moment.
Before the exception I get such a printout:
Driver available: [<class 'ant.base.driver.SerialDriver'>, <class 'ant.base.driver.USB2Driver'>, <class 'ant.base.driver.USB3Driver'>]
- Using: <class 'ant.base.driver.USB3Driver'>
Could not check if kernel driver was active, not implemented in usb backend
I have seen other users' threads where the printout says Using ... USB1Driver or Using ... USB2Driver, and they don't get this message. I've installed various python libraries trying to get even this far, and now I've worried that maybe they get in each other's way.. Can anybody help me with this? It's really frustrating that a program of only two code lines can get so complicated.. :D
!!!EDIT!!!
OK, I found the problem - in the "driver.py" file there's a line dev.reset() which disconnects my USB dongle before trying to access it. I have no idea why such a line should exist there. I tried to comment this line out, and now I'm not getting the abovementioned error anymore. However, what happens now is there are continuos timeouts..
So my code has evolved to this (although actually the same timeouts happen also with my initial 2-lines-long program):
from ant.easy.node import Node
from ant.easy.channel import Channel
from ant.base.message import Message
import threading
NETWORK_KEY=[0xb9,0xa5,0x21,0xfb,0xbd,0x72,0xc3,0x45]
def on_data(data):
print("Data received")
print(data)
def back_thread(node):
node.set_network_key(0x00,NETWORK_KEY)
channel=node.new_channel(Channel.Type.BIDIRECTIONAL_RECEIVE)
channel.on_broadcast_data=on_data
channel.on_burst_data=on_data
channel.set_period(16070)
channel.set_search_timeout(20)
channel.set_rf_freq(57)
channel.set_id(0,120,0)
try:
channel.open()
node.start()
finally:
node.stop()
print("ANT Node Shutdown Complete")
node=Node()
x=threading.Thread(target=back_thread,args=(node,))
x.start()
Now I get this error line printed out for ever:
<class 'usb.core.USBError'>, (None, b'libusb0-dll:err [_usb_reap_async] timeout error\n')
When my Garmin Agent is active, I get the error "ANT resource already in use" instead of the timeout, so I'm certain that my code is accessing the ANT dongle.. However, now (having closed the Garmin Agent) I have no idea about how to get rid of the timeout and how to establish a simple handshake with my Garmin device..
OK, now I've figured out that my Garmin Forerunner 310XT can't act as a data source and thus cannot be accessed using the ANT+ protokol. Instead, I should use the ANT-FS protocol of File Sharing. Keeping my head down and trying it out...
I posted a PR with some changes that I made to get Tigge’s openant library to work. Basically, I put a pause after the reset line that you mentioned above and bypassed the use of udev_rules as it doesn’t apply in Windows. You can use libusb but installation is a bit different. I’ve added Windows installation instructions to the readme in the PR with details on what worked for me.

Robotframework "Choose file" causes AttributeError: module 'base64' has no attribute 'encodestring' in docker

I'm trying to run a test in a docker container, which runs locally with no issues:
I want to upload a correct.csv file from 'correct' directory
*** Keyword ***
Upload file
[Arguments] ${directory} ${file}
Choose File ${choose_file_input} ${EXECDIR}/Files/${directory}/${file}
** Test case ***
Upload
Upload file correct correct.csv
But when running test in docker I get a FAIL with the AttributeError: module 'base64' has no attribute 'encodestring'. Is it because there is no GUI in docker? or the encoding needs to be fixed? Or eventually maybe there is another solution I can use for uploading files?
15:20:01.250 INFO Sending /App/Files/correct/correct.csv to browser.
15:20:01.251 DEBUG POST http://192.168.1.29:4444/wd/hub/session/4b6d453b394adaaa51bb4149e9ba8678/elements {"using": "xpath", "value": "//div[#id=\"upload\"]//input"}
15:20:01.252 DEBUG Starting new HTTP connection (1): 192.168.1.29:4444
15:20:01.305 DEBUG http://192.168.1.29:4444 "POST /wd/hub/session/4b6d453b394adaaa51bb4149e9ba8678/elements HTTP/1.1" 200 90
15:20:01.305 DEBUG Finished Request
15:20:01.618 FAIL AttributeError: module 'base64' has no attribute 'encodestring'
15:20:01.619 DEBUG Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/SeleniumLibrary/__init__.py", line 490, in run_keyword
return DynamicCore.run_keyword(self, name, args, kwargs)
File "/usr/local/lib/python3.9/site-packages/robotlibcore.py", line 103, in run_keyword
return self.keywords[name](*args, **(kwargs or {}))
File "/usr/local/lib/python3.9/site-packages/SeleniumLibrary/keywords/formelement.py", line 224, in choose_file
self.find_element(locator).send_keys(file_path)
File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/remote/webelement.py", line 475, in send_keys
value = self._upload(local_file)
File "/usr/local/lib/python3.9/site-packages/selenium/webdriver/remote/webelement.py", line 695, in _upload
content = base64.encodestring(fp.getvalue())
Based on the traceback you have found this issue:
Selenium 3 is incompatible with Python 3.9
This is the fix for the issue: DeprecationWarning of base64.encodestring().
They won't back port this fix:
Thanks for the issue. We won't be releasing another version 3 as we're
heading to finishing off Selenium 4. It is a drop in replacement to
use Selenium 4.0.0.a5 so should work the same. There should not be any
breaking changes.
So you could upgrade selenium to Selenium 4.0.0.a5 or
Downgrade Python to 3.7 for example. I suppose locally you do not run 3.9.
We were running into this issue as well, but going back to an older version of Python was not an option due to incompatibilities with other libraries. If you find yourself in the same spot, you can re-create the alias like so:
import base64
base64.encodestring = base64.encodebytes
In whatever your entry-point is.

Unable to run PyTest-bdd step definition file as it throws index out of range error

Feature file is as below
Feature: Nopcommerce Login
Scenario: login to nopcommerce website
Given nopcommerce page is displayed
When user enters username as admin#yourstore.com
When user enters password as admin
Then user is able to login to nocpmmerce website
step definition python file is as below
from pytest_bdd import scenarios, given, when, then
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import pytest
scenarios('../features/NopcommerceLogin.feature')
#pytest.fixture()
def browser():
driver = webdriver.Safari()
yield driver
driver.quit()
#given("nopcommerce page is displayed")
def webpage(browser):
browser.get("http://admin-demo.nopcommerce.com")
#when("user enters username as admin#yourstore.com")
def enter_uname(browser):
browser.find_element_by_id("Email").send_keys("admin#yourstore.com")
#when("user enters password as admin")
def enter_pwd(browser):
browser.find_element_by_id("Password").send_keys("admin")
browser.find_element_by_xpath("/html/body/div[6]/div/div/div/div/div[2]/div[1]/div/form/div[3]/input").click()
#then("user is able to login to nocpmmerce website")
def loginsuccess(browser):
assert browser.current_url == "https://admin-demo.nopcommerce.com/admin/"
when the step_def file is run, the following error message is displayed
Traceback (most recent call last):
File "~/tests/step_defs/test_NopcommerceLogin.py", line 6, in
scenarios('../features/NopcommerceLogin.feature')
File "~/venv/lib/python3.8/site-packages/pytest_bdd/scenario.py", line 343, in scenarios
features_base_dir = get_features_base_dir(module)
File "~/venv/lib/python3.8/site-packages/pytest_bdd/scenario.py", line 295, in get_features_base_dir
return get_from_ini('bdd_features_base_dir', default_base_dir)
File "~/venv/lib/python3.8/site-packages/pytest_bdd/scenario.py", line 303, in get_from_ini
config = CONFIG_STACK[-1]
IndexError: list index out of range
It's not entirely the solution, and I have the same issue in PycharmIDE, but I suggest using terminal and start tests like:
pytest <test_fily.py>
for IDEA solution, still working on it
Change your configurations to use pytest configuration: screenshot
or try running using terminal : pipenv run python -m pytest
I guess the problem is that the pytest is not identifying any executable pytest method's in your step definition file. Please try changing the "scenarios" to "scenario" and add a pytest identifiable method below the same
#scenario('../features/NopcommerceLogin.feature')
def test_login():
pass
This approach always works for me and is based on Pytest-BDD doc.
Make sure that pytest configured in pycham
Enable Pytest for your project
Open the Settings/Preferences | Tools | Python Integrated Tools settings dialog as described in Choosing Your Testing Framework.
In the Default test runner field select pytest.
Click OK to save the settings
#Vova
I found that in the run configuration, the Working directory was incorrectly set to the directory where the steps python file was, instead of the project root directory.
Fixing that made the test run successfully in PyCharm.
I had this issue - it was simply alignment in the feature file, I had a space on the Scenario definition after 'Scenario' and before the colon. When I removed - the error no longer occured.

Selenium "Unable to find a matching set of capabilities" despite driver being in /usr/local/bin

I'm trying to follow a tutorial about Selenium, http://selenium-python.readthedocs.io/getting-started.html. I've downloaded the latest version of geckodriver and copied it to /usr/local/bin. However, when I try
from selenium import webdriver
driver = webdriver.Firefox()
I get the following error message:
Traceback (most recent call last):
File "/Users/kurtpeek/Documents/Scratch/selenium_getting_started.py", line 4, in <module>
driver = webdriver.Firefox()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 152, in __init__
keep_alive=True)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 98, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 188, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in execute
self.error_handler.check_response(response)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Unable to find a matching set of capabilities
[Finished in 1.2s with exit code 1]
From https://github.com/SeleniumHQ/selenium/issues/3884, it seems like other users are experiencing similar issues, but the Selenium team is unable to reproduce it. How can I get Selenium working with Firefox? (It does work with chromedriver and a webdriver.Chrome() instance, so I suspect this might be a bug in Selenium).
Updating Firefox and Selenium solved it for me. I don't pretend to have an explanation for the root cause however.
Updated Firefox 48 → 53
Updated to Selenium 3.4.1
I also reinstalled/updated Geckodriver using Homebrew and explicitly used it as an executable for Selenium WebDriver, but it turned out that it wasn't necessary to mitigate the "Unable to find matching set of capabilities" error.
I had this same issue, and the problem was related to using Firefox ESR (I'm on Debian). To be more specific, I'm on Debian 10 using 64-bit Firefox 68.11.0esr, python3.7, selenium 3.141.0, and geckodriver 0.27.0.
Here's the standard example I used that failed:
from selenium import webdriver
browser = webdriver.Firefox()
browser.get("http://google.com")
As recommended in this answer, I changed:
browser = webdriver.Firefox()
to
browser = webdriver.Firefox(firefox_binary="/usr/bin/firefox-esr")
and it worked.
If you don't know the path to firefox-esr, you can run sudo find / -name firefox-esr on the command line. Several should come up.
for me it was enough to just upgrade FF
Mac user here.
I fixed this issue by making sure Firefox is named "Firefox" and in the "Applications" folder. I had called it "Firefox 58" before (I have multiple versions).
Just sharing my success case here
Note: Remember the Architecture matters here, Window 64/32 or Linux 64/32. Make sure you download the right 64/32 bit Selenium Webdriver, 64/32 Geckodriver.
My configuration was as follows:
Linux: Centos 7 64bit, Window 7 64bit
Firefox: 52.0.3
Selenium Webdriver: 3.4.0 (Windows), 3.8.1 (Linux Centos)
GeckoDriver: v0.16.0 (Windows), v0.17.0 (Linux Centos)
Working Code (Without Proxy Settings)
System.setProperty("webdriver.gecko.driver", "/home/seleniumproject/geckodrivers/linux/v0.17/geckodriver");
ProfilesIni ini = new ProfilesIni();
// Change the profile name to your own. The profile name can
// be found under .mozilla folder ~/.mozilla/firefox/profile.
// See you profile.ini for the default profile name
FirefoxProfile profile = ini.getProfile("default");
DesiredCapabilities cap = new DesiredCapabilities();
cap.setAcceptInsecureCerts(true);
FirefoxBinary firefoxBinary = new FirefoxBinary();
GeckoDriverService service =new GeckoDriverService.Builder(firefoxBinary)
.usingDriverExecutable(new File("/home/seleniumproject/geckodrivers/linux/v0.17/geckodriver"))
.usingAnyFreePort()
.build();
try {
service.start();
} catch (IOException e) {
e.printStackTrace();
}
FirefoxOptions options = new FirefoxOptions().setBinary(firefoxBinary).setProfile(profile).addCapabilities(cap);
driver = new FirefoxDriver(options);
driver.get("https://www.google.com");
System.out.println("Life Title -> " + driver.getTitle());
driver.close();
Working Code (With Proxy Settings)
System.setProperty("webdriver.gecko.driver", "/home/seleniumproject/geckodrivers/linux/v0.17/geckodriver");
String PROXY = "my-proxy.co.jp";
int PORT = 8301;
ProfilesIni ini = new ProfilesIni();
// Change the profile name to your own. The profile name can
// be found under .mozilla folder ~/.mozilla/firefox/profile.
// See you profile.ini for the default profile name
FirefoxProfile profile = ini.getProfile("default");
com.google.gson.JsonObject json = new com.google.gson.JsonObject();
json.addProperty("proxyType", "manual");
json.addProperty("httpProxy", PROXY);
json.addProperty("httpProxyPort", PORT);
json.addProperty("sslProxy", PROXY);
json.addProperty("sslProxyPort", PORT);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setAcceptInsecureCerts(true);
cap.setCapability("proxy", json);
FirefoxBinary firefoxBinary = new FirefoxBinary();
GeckoDriverService service =new GeckoDriverService.Builder(firefoxBinary)
.usingDriverExecutable(new File("/home/seleniumproject/geckodrivers/linux/v0.17/geckodriver"))
.usingAnyFreePort()
.usingAnyFreePort()
.build();
try {
service.start();
} catch (IOException e) {
e.printStackTrace();
}
FirefoxOptions options = new FirefoxOptions().setBinary(firefoxBinary).setProfile(profile).addCapabilities(cap);
driver = new FirefoxDriver(options);
driver.get("https://www.google.com");
System.out.println("Life Title -> " + driver.getTitle());
driver.close();
In my case, I only have Firefox Developer Edition but still throw same error.
After installing a standard Firefox version, it solves.
I had the same issue. My geckodriver was 32 bit and fireFox was 64. Resolved by updating geckodriver to 64 bit.
I had exactly the same issue when i was using selenium firefox()
>> webdriver.Firefox()
it was not working : throwing error like "Unable to find a matching set of capabilities"
Then i installed geckodriver.exe and that put that .exe file inside the both directory
C:\Users\<USER-NAME>\AppData\Local\Programs\Python\Python36\Scripts
and
C:\Users\<USER-NAME>\AppData\Local\Programs\Python\Python36\
and set these two paths in the environment setting
then it started working
Here's the solution that solved it for me. Don't overlook this point: make sure you're using the correct 32/64 bit version of the binaries - it should be uniform - e.g. if the firefox is 64bit, so must be the geckodriver.
Got the same error on a droplet at DigitalOcean - FireFox was not installed . Stack trace of error was as seen below -
exception_class
<class 'selenium.common.exceptions.SessionNotCreatedException'>
json
<module 'json' from '/usr/lib/python3.5/json/__init__.py'>
message
'Unable to find a matching set of capabilities'
response
{'status': 500,
'value': '{"value":{"error":"session not created","message":"Unable to find a '
'matching set of capabilities","stacktrace":""}}'}
screen
None
self
<selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x7f428e3f10f0>
stacktrace
None
status
'session not created'
value
{'error': 'session not created',
'message': 'Unable to find a matching set of capabilities',
'stacktrace': ''}
value_json
('{"value":{"error":"session not created","message":"Unable to find a matching '
'set of capabilities","stacktrace":""}}')
It seems like different workarounds are seem to make the error go away. After ensuring you have downloaded and installed the 64bit versions for Firefox and geckodriver.exe, update the PATH with the location of the geckodriver.exe. What may also help before running the script, launch the geckodriver.exe which opens a cmd like window. Now if you run the py script, you shouldn't run into the error below:
selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities

Error "The object invoked has disconnected from its clients" - automate IE 8 with python and win32com

I would like to automate Internet Explorer 8 (using python 2.7 on Windows 7) machine. Here is my code after a post found on SO:
import sys, time
from win32com.client import WithEvents, Dispatch
import pythoncom
import threading
stopEvent=threading.Event()
class EventSink(object):
def OnNavigateComplete2(self,*args):
print "complete",args
stopEvent.set()
def waitUntilReady(ie):
if ie.ReadyState!=4:
while 1:
print "waiting"
pythoncom.PumpWaitingMessages()
stopEvent.wait(.2)
if stopEvent.isSet() or ie.ReadyState==4:
stopEvent.clear()
break;
if __name__ == '__main__':
time.clock()
ie=Dispatch('InternetExplorer.Application',EventSink)
ev=WithEvents(ie,EventSink)
ie.Visible=True
ie.AddressBar = True
ie.Navigate("http://www.sap.com/austria/index.epx")
waitUntilReady(ie)
I got the following error message for http://www.sap.com/austria/index.epx:
waiting
waiting
Traceback (most recent call last):
File "C:\Users\w\My Documents\Aptana Studio 3 Workspace\MyApp\src\GoToIdeaWindow.py", line 41, in <module>
waitUntilReady(ie)
File "C:\Users\w\My Documents\Aptana Studio 3 Workspace\MyApp\src\GoToIdeaWindow.py", line 26, in waitUntilReady
if stopEvent.isSet() or ie.ReadyState==4:
File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 463, in __getattr__
return self._ApplyTypes_(*args)
File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 456, in _ApplyTypes_
self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args),
pywintypes.com_error: (-2147417848, 'The object invoked has disconnected from its clients.', None, None)
The code works perfectly for, e.g., google.com or bbc.com. Does anybody know what could be a reason?
On IE9, you need to lower security settings to make the script work:
IE9 -> Internet Options -> Security -> Trusted Sites : Low
IE9 -> Internet Options -> Security -> Internet : Medium + unchecked Enable Protected Mode
IE9 -> Internet Options -> Security -> Restricted Sites : unchecked Enable Protected Mode
Wow. I have been fighting with a script that was working for 3 days trying to figure out why it did not even reach the 10th line. Microsoft has been auto-updating Internet Explorer silently to IE10 throughout our organisation and it has caused major headaches for the CRM developers. I noticed now that the settings has been reset to default and that protected mode has been turned on.
One of the most useful things you can try while developing your site is pushing F12 and setting the IE version to other versions. For example, your site used to work in IE9 but broke in 10. This allows you to be running IE10 and test your code in multiple versions. I am still trying to find a way to force certain websites to open in specific versions of internet explorer without having to push F12 every time.
I could not change my ie security setting but i found another solution that works in vbscript (dont ask me why i am using that :D)!
http://go-gaga-over-testing.blogspot.co.uk/2013/06/the-object-invoked-has-disconnected.html
Set ie = WScript.CreateObject("InternetExplorer.Application")
With ie
hwnd = .hwnd
.Navigate theURL
End With
Set oShell = CreateObject("Shell.Application")
For Each Wnd In oShell.Windows
If hwnd = Wnd.hwnd Then Set ie = Wnd
Next
I had somewhat similar issue, what I did was (however it was using mshtml and SHDocVw in C#.NET):
Lowered the security (in security tab of Internet options) levels in internet explorer (just as you #Skarab had tried doing) ,
Initialized internet explorer variable to a null value like:
/*INITIALIZE THE BROWSER VARIABLE TO NULL VALUE*/
SHDocVw.InternetExplorer ie =null;
ie = new SHDocVw.InternetExplorer();
hope this helps...

Categories

Resources