I am trying to use the Select function in Selenium for Python 3 to help with navigating through the drop down boxes. However, when I try to import org.openqa.selenium.support.ui.Select I get an error message:
"No module named 'org'"
Would appreciate any help on this. I saw there was a similar question posted a few weeks ago but the link to that question is now broken. Thanks!
The path 'org.openqa.selenium.support.ui.Select' is a Java descriptor. In Python, make sure you have the Python Selenium module installed with pip install selenium, and then import it with import selenium.
For the Select function specifically, you can import that with the following
from selenium.webdriver.support.ui import Select
Then you'll be able to use it like this:
select = Select(b.find_element_by_id(....))
Related
I was trying to insert a js code into a website using selenium.
I know that I want to use the following import statement,
import org.openqa.selenium.JavascriptExecutor
But this was not installed,
"org.openqa.selenium.JavascriptExecutor" is not accessed
Import "org.openqa.selenium.JavascriptExecutor" could not be resolved
where to install the module or how to resolve the problem
You have tagged python and using the Selenium-Python clients you don't require any additional import other then from selenium import webdriver as both the methods to execute JavaScript synchronously and asynchronously i.e.
execute_script()
execute_async_script()
are supported out of the box.
Where as incase you are using the Selenium-Java clients you additionally need to import:
import org.openqa.selenium.JavascriptExecutor;
Question.
I am a noob, what is the difference between this:
import selenium
And this
from selenium import webdriver.
Doesn't import selenium automatically import webdriver?
Yes it does but the use is different.
When you type from selenium import webdriver you can access it by typing webdriver in your code.
But when you run import selenium you can access webdriver by typing selenium.webdriver.
Sometimes you want to make clear where this function is from like in django urls I always type from . import views so I can then type views.myfunction in code.
For import selenium, names are accessed via selenium.nameX. You also have access to the entire selenium package.
With from selenium import webdriver, you are importing only webdriver from the selenium package. You do not have access to the entire selenium package. In the second case, you also access names from webdriver via webdriver.nameX, not selenium.webdriver.nameX.
yes but if you just import selenium you would have to do selenium.webdriver.functionyouwant instead of just webdriver.functionyouwant
When you type import package, you can access module by typing package.module.
When you type from package import module, you can access module by typing module and you can't use other modules in package package.
I am a beginner trying to learn web scraping with python. I tried to import RoboBrowser module in Python 3.7.
When I install it using pip install robobrowser in the terminal, I get a list of 'Requirement already satisfied'. So I am assuming its installed properly.
However when I run from robobrowser import RoboBrowser in Python, its gives an import error as shown below.
ImportError: cannot import name 'cached_property' from 'werkzeug' (/Users/ashreetsangotra/opt/anaconda3/lib/python3.7/site-packages/werkzeug/__init__.py)
Here is the screenshot of the complete error for reference:
Click here for the screenshot Sorry Stack Overflow won't let me embed the screenshot directly as for now.
Please advice on how to proceed.
Ashreet Sangotra
Make sure your Werkzeug==0.16.1 version,
it will solve your error.
Thanks
I don't know whether I've just installed them wrong or there's another problem. I installed the ebay sdk but whenever I try to import it I get
ModuleNotFoundError: No module named 'ebaysdk'
Are there any common problems with this I could check for a solution? It shouldn't be the code as I copied it from the example code off the website.
Thanks for any help.
P.S I'm using 3.6
I'm going to make an application using the Selenium WebDriver (python) and I was having trouble with some of the initial setup. I want to use the page object design pattern so I've been trying to import some materials in this way:
from page_objects import PageObject, PageElementfrom page_objects import PageObject, PageElement
as can bee seen in the documentation here: https://page-objects.readthedocs.io/en/latest/tutorial.html#a-simple-page-object
I'm using PyCharm for development and I've updated selenium and added it to the project interpreter but this import statement still will not work for me. I'm not sure which external module this import relates to or if its just some part of selenium, so any information would be greatly appreciated. Thanks!
That readthedocs is for the page_objects library, the repo for that library can be found here. You need to install that library before you can import it