1

This command entered in Python's interpreter opens a new FireFox window:

webdriver.Firefox(executable_path='C:\\...\\geckodriver.exe').get('https://doesnmatter/')

But then when I want to locate elements, but this open another Firefox window:

elements = driver.find_elements_by_xpath("//*doesnmatter")

How do I locate elements in the first Firefox window from Python console?

1 Answer 1

1

I have recreated your use case and tried a simple solution, First run the below command (assuming you have already imported neccessary libraries)

browser= webdriver.Firefox()

This command will launch a firefox instance. Once you have the "browser" object available, you can perform any action on this instance, for example,

browser.get("http://some_website.com")
ele_of_xpath=browser.find_element_by_xpath("xpath_of_the_element")

In this way you can keep performing activities using command line (in my case it is mac terminal) on the same browser instance.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.