Home > Blockchain >  I have different number of quotes to concatinate so make a complete Xpath but getting error,
I have different number of quotes to concatinate so make a complete Xpath but getting error,

Time:02-03

I am storing 2 strings and concatinating to make a complete xpath for for script

    rowc = driver.find_elements(By.XPATH, '//*[@]|//*[@]')
    i = len(rowc)
    extstr1 = "//*[@id="m_mc_s0_igSearch_ctl00_ctl00__
    extstr2 = "]/td[13]"
    for i in range(0):
        extval = driver.find_element_by_xpath(extstr1 i extstr2)

I am getting the below error :

  extstr1 = "//*[@id="m_mc_s0_igSearch_ctl00_ctl00__
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 SyntaxError: invalid syntax. Perhaps you forgot a comma?

CodePudding user response:

Change your code like this:

extstr1 = "//*[@id='m_mc_s0_igSearch_ctl00_ctl00__'"
extstr2 = "]/td[13]"

You need to change the " in extstr1 into '

CodePudding user response:

Ok Answer was simple I had to declare it as below inside quotes

 extstr1 = '"//*[@id="m_mc_s0_igSearch_ctl00_ctl00__'
 extstr2 = '"]/td[13]"'
  •  Tags:  
  • Related