selserver = subprocess.Popen(["java", '-jar', r"C:\selenium-remote-control-1.0.1\selenium-server-1.0.1\selenium-server.jar"])
and then connect to it. Works fine, but less is more...
Installing Selenium in Python
I installed Selenium using pip install selenium. I'm using Python 2.7.1. There where two syntax errors while installing in webdriver\mouse.py. and keyboard.py I guess this needs repairing at some point...
But first let's see if it works. In Python I can now
from selenium import webdriver driver = webdriver.Chrome()
This gives me an exception, apparently I need an executable, to replace the former selenium server, but now a specialized browserspecific one. You can find it at http://code.google.com/p/selenium/downloads/list I downloaded chromedriver_win32_12.0.727.0.zip since I'm on Windows 7, unzipped it and placed the executable in a folder and made it reachable with my PATH by changing this environment variable.
Now my code - after starting a server in the background - opens a Chrome browser instance, which is good news. Let's see if we can control it by sending the browser to my app url at 127.0.0.1:8000/dibsa. This is the Web2py application I want to test. And let's say we want to login, and the menu item, the link to login is 'Login'
from selenium import webdrive driver = webdriver.Chrome() driver.get("http://127.0.0.1:8000/dibsa") link=driver.find_element_by_partial_link_text("Login") link.click() driver.quit()
This code, in the opened browser now redirects to the login page. We can now continue to fill in the inputs, and then clicking the submit button. I could have used other methods like find_element_by_xpath() to select the link.
When ready you can close the browser with the close() method, but in that case the chromedriver binary stays in memory. If you use quit() it ends. If you first call close() and then quit() the selenium module crashes.
Conclusion
Selenium 2 seems to work fine, at least with Chrome. The server-executables are an improvement. No configuring needed, no fiddling with profiles and no java. Don't forget to end the chromedriver process by calling the quit() method.
I am seeing an crash or exception even with just close. Did you find any solution for fixing this issue? Please do let me know.
ReplyDeleteI'm not having an issue, it's working for me on Windows 7 and on Mac. What's your setup? Mine is Python 2.7, current selenium module installed with pip, and the binary/executable chromedriver installed in my path.
ReplyDeleteExcellent incredible blog layout! How long have you been blogging for? you make running a blog look easy. The overall glance of your website is magnificent, let alone the content!
ReplyDeleteSelenium Training in Chennai
Really it was an awesome article about JAVA, very interesting to read.You have provided an nice article,Thanks for sharing.
ReplyDeleteJava training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery
The contents are good.I am expecting for further more updates.
ReplyDeleteJava training in Chennai | Certification | Online Course Training | Java training in Bangalore | Certification | Online Course Training | Java training in Hyderabad | Certification | Online Course Training | Java training in Coimbatore | Certification | Online Course Training | Java training in Online | Certification | Online Course Training
this article is interesting to read
ReplyDeletebest-angular-training in chennai |
mmorpg oyunlar
ReplyDeleteİNSTAGRAM TAKİPÇİ SATİN AL
TİKTOK JETON HİLESİ
tiktok jeton hilesi
Antalya Sac Ekimi
INSTAGRAM TAKİPÇİ SATİN AL
instagram takipçi satın al
METİN2 PVP SERVERLER
instagram takipçi satın al