mrkn / pycall.rb

Calling Python functions from the Ruby language
MIT License
1.05k stars 72 forks source link

Question about loading a subclass #153

Closed sebyx07 closed 2 years ago

sebyx07 commented 2 years ago

Hey, I try to use by.XPATH

here is the code:

pyimport 'selenium.webdriver.common.by', as: 'by'

by.XPATH # raises undefined method `XPATH' for
by::XPATH # raises uninitialized constant <module 'selenium.webdriver.common.by' 
mrkn commented 2 years ago

@sebyx07 As you can see this document, XPATH attribute is defined in By class instead of by module.

irb(main):001:0> by = PyCall.import_module("selenium.webdriver.common.by")
=> <module 'selenium.webdriver.common.by' from '/home/mrkn/.local/lib/python3.9/site-packages/selenium/webdriver/common/by.py'>
irb(main):002:0> by.By.XPATH
=> "xpath"