0

Hey guys

I'm currently writing a bot for my typing-learning website, but i bumped into a problem that my own googling couldn't solve:

if answerBrowser == "f":
  driver = webdriver.Firefox()
elif answerBrowser == "c":
  driver = webdriver.Chrome("driver\chromedriver.exe")
elif answerBrowser == "e":
  driver = webdriver.Edge("driver\msedgedriver.exe")

driver.get("https://at4.typewriter.at/index.php?r=site/index")

Here I made a "driver" object and then opened it with driver.get(link), however, after i am done doing my stuff on the website, I want to just open another link (in the same tab ofc.). I tried:

driver.get("https://at4.typewriter.at/index.php?r=user/overview")

(I am trying this because the link to the overview page is really hard to scrape and I think it's easier to just change the url completly) Its the same "driver"-object, but just driver.get() wont let me change the url.

Here's the git repos for the entire code:

https://github.com/patrickcerny/typewriterBot/tree/testing

(I'm a beginner in coding so please don't hate on my code too much, however I'm open for any constructive critism I can get! :D) Thanks for any answers!

5
  • What happens when you try to just open another link (in the same tab ofc.) Commented Aug 14, 2020 at 21:22
  • actually it does nothing. it just stays right as it is Commented Aug 14, 2020 at 21:24
  • Is the second url manually reachable? Commented Aug 14, 2020 at 21:26
  • If you understand "manually reachable" as being able to paste the link into the browser and getting to the website yes. If you are logged in before (which i did beforehand with my script) you should get to the specified website Commented Aug 14, 2020 at 21:28
  • why do you use if answerBrowser == "f": driver = webdriver.Firefox() .... so many times ? You should use it only once and later use only this driver all time. You should create special function only to select and create driver. Commented Aug 14, 2020 at 21:44

1 Answer 1

1

It should work:

https://selenium-python.readthedocs.io/getting-started.html says

The driver.get method will navigate to a page given by the URL. WebDriver will wait until the page has fully loaded (that is, the “onload” event has fired) before returning control to your test or script. It’s worth noting that if your page uses a lot of AJAX on load then WebDriver may not know when it has completely loaded.:

driver.get("http://www.python.org")
Sign up to request clarification or add additional context in comments.

1 Comment

Got it to work, just had to add time.sleep(1), the website didnt have enought time to load properly :/

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.