Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't get "print" output in colsole with selenium + python

The problem is, I can't see my print in console, although I should!

def test_123(app):
 wd = app.wd
 app.open_page("page_adress")
 time.sleep(3)
 element = wd.find_element_by_xpath("locator").text
 print(element)

String from my app file:

wd = webdriver.Chrome()

My test runs successful. And one more thing! If after my print command I'm putting some string which leads my test to the crash, I can see print with all other crash information.

like image 492
Ser Jah Avatar asked Jun 27 '26 03:06

Ser Jah


1 Answers

The problem is, I can't see my print in console, although I should!

If you use behave as the launcher for the Selenium tests, you can solve this by passing --no-capture as an argument in your behave command:

behave -i  my_feature.feature --no-capture

Without this argument, outputs from print() are captured and discarded.

like image 117
Luis Moita Avatar answered Jun 29 '26 18:06

Luis Moita