When there are multiple Selenium SeleniumBasic classes (Python VBA)

If you want to get an element with multiple classes in Selenium

↓ There are multiple classes as shown in the example.

Multiple classes


<ul class="topic-path under-menu-title">

Conclusion

Use CSS functions

Connect the classes with. Delete the blanks so as not to forget the leading.

Because it's a class find_element_by_class_name FindElementByClass I'm wondering if I'm going to use CSS functions.

For SeleniumBasic VBA

↓ It is assumed that the Selenium Basic driver has already been set for the driver.
An example of getting an element in a and displaying a string.

Dim a as WEbelement
set a = driver.FindElementByCss(".topic-path.under-menu-title")
Debug.print(a.Text)← The text of the element is displayed.

For Selenium Python

↓ It is assumed that the Selenium driver has already been set for the driver.
An example of getting an element in a and displaying a string.
a = driver.find_element_by_class_name(".topic-path.under-menu-title")
print(a.text)

CSS-coded popup buttons, etc. Often things that don't work with xpath or class work well with CSS. So when things go wrong Try all xpath, class, css.

Recommended Posts

When there are multiple Selenium SeleniumBasic classes (Python VBA)
How to write a string when there are multiple lines in python
Python classes are slow
Half-width katakana characters are not garbled when using python + selenium execute_script
Extension of Python by C or C ++ (when there are multiple arguments, when passing a list from the Python side)
Creating an alias (when there are multiple arguments) [Comparison between Bash and PowerShell]
How python classes and magic methods are working.
[Python] Ravel () is convenient when drawing multiple graphs
I can't click the Selenium checkbox Python VBA
Multiple graphs are displayed in one window (python)
What are you using when testing with Python?