Last active
October 1, 2015 05:42
-
-
Save VladSem/d08bcfd3b894d506b752 to your computer and use it in GitHub Desktop.
how to find text between two specific characters in Firefox XPath and Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Firefox XPath | |
# Full XPath = html/body/div[5]/form/table/tbody/tr/td[2]/table/tbody/tr/td/div/span[4] | |
# Result: SWI9X15C_05.05.16.02 r21040 carmd-fwbuild1 2014/03/17 23:49:48 | |
# XPath: substring-before(substring-after(//span[4], 'C_'), ' r') | |
# Result: 05.05.16.02 | |
# Python Selenium/Webdriver | |
get_firmware_version = browser.find_element_by_xpath("//span[4]").text | |
# Result: get_firmware_version = SWI9X15C_05.05.16.02 r21040 carmd-fwbuild1 2014/03/17 23:49:48 | |
a = 'C_' | |
b = ' r' | |
firmware = get_firmware_version.split(a)[1].split(b)[0] | |
print firmware # 05.05.16.02 | |
firmware2 = get_firmware_version[get_firmware_version.find('C_')+2:get_firmware_version.find(' r')] | |
print firmware # 05.05.16.02 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment