Python Forum
How to let browser to assigned web - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: How to let browser to assigned web (/thread-1819.html)



How to let browser to assigned web - Baal - Jan-27-2017

Hi all,

I want to my chrome browser to assigned web
but chrome browser just show  frontpage of browser

The code was this...

   from selenium import webdriver

   browser = webdriver.Chrome("C:\Program Files\Google\Chrome\Application\Chrome.exe")
   browser.get('web url')
I was hoping for some guidance or advice really. Somewhere I can start from to solve the problem and answer the questions.

Thanks,


RE: How to let browser to assigned web - Larz60+ - Jan-27-2017

Have you looked at the documentation http://www.seleniumhq.org/docs/03_webdriver.jsp?

That document suggests that you use Maven to test and has other info you may need.


RE: How to let browser to assigned web - snippsat - Jan-28-2017

Have you give web_url a variable?
So this open the Python website.
from selenium import webdriver

browser = webdriver.Chrome()
web_url = 'https://www.python.org/'
browser.get(web_url)
Selenium is used for testing websites or web-scraping.
So here it will click on documentation tab and click on tutorial link.
from selenium import webdriver
import time

browser = webdriver.Chrome()
web_url = 'https://www.python.org/'
browser.get(web_url)
time.sleep(2)
browser.find_element_by_css_selector('#top > nav > ul > li.docs-meta > a').click()
time.sleep(2)
browser.find_elements_by_xpath('html/body/div[2]/div[1]/div/div/table[1]/tbody/tr/td[1]/p[2]/a')[0].click()