views:

53

answers:

1

When I call selenium.get_text("foo") on a certain element it returns back a different value depending on what browser I am working in due to the way each browser handles newlines.

Example:

An elements string is "hello[newline]how are you today?[newline]Very well, thank you."

When selenium gets this back from IE it gets the string "hello\nhow are you today?\nVery well, thank you."

When selenium gets this back from Firefox it gets the string "hello\n how are you today?\n Very well, thank you."

(Notice that IE changes [newline] into '\n' and Firefox changes it into '\n ')

Is there anyway using selenium/python that I can easily strip out this discrepancy?

I thought about using .replace("\n ", "\n"), but that would cause issues if there was an intended space after a newline (for whatever reason).

Any ideas?

A: 

I ended up just doing a check of what browser I was running and then returning the string with the '\n ' replaced with '\n' if the browser was firefox.

wierddemon