Super-specifically, I use By in the Python API of WebDriver, but I want to know what this declares. I remember `By.NAME```, but I wonder if it is
By.CLASS_NAME``` or ``
By.CLASS```.
At that time, I would do something like ``` locate'/ usr * python * webdriver * by *'` ``, which is kind of stupid.
> locate '/usr*python*/webdriver*by*'
/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/by.py
/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/by.pyc
(See in view or emacs)
I will introduce the method of ipython as a bean knowledge. Just add two?
In [1]> from selenium.webdriver.common.by import By
In [2]> By??
Type: type
String form: <class 'selenium.webdriver.common.by.By'>
File: /usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/by.py
Source:
class By(object):
"""
Set of supported locator strategies.
"""
ID = "id"
XPATH = "xpath"
LINK_TEXT = "link text"
PARTIAL_LINK_TEXT = "partial link text"
NAME = "name"
TAG_NAME = "tag name"
CLASS_NAME = "class name"
CSS_SELECTOR = "css selector"
@classmethod
def is_valid(cls, by):
for attr in dir(cls):
if by == getattr(cls, attr):
return True
return False
For some reason, there was an introductory article on ipython in the book "Introduction to Data Analysis with Python", and I thought again that it was a shame that I didn't know the tool I was using.
The iPython cheat sheet is as follows.
http://damontallen.github.io/IPython-quick-ref-sheets/
This is also from the same book, but I was shocked soberly, so for reference (python-matplotlib package etc. are required first)
> ipython --pylab
In [1]> plot(np.random.randn(100).cumsum())
See https://www.youtube.com/watch?v=BrDJssegqwo to see how it works
Recommended Posts