1

I have a form which opens as a popup or iframe (I am not sure), and it has a cross icon which can close the popup.

Code of cross icon:

<a onclick="hideLayer('layer_1')" href="javascript:void(0)" class="cls11"></a>

I'd like to know how to simulate this in python-selenium. I used find_element_by_xpath and click(), but it gave SyntaxError.

Selenium-code:

a = self.driver.find_element_by_xpath("//*[@id="xyz"]/a")
a.click()

It gives an error window - "invalid syntax in your program".

Daniel
  • 2,345
  • 4
  • 19
  • 36
Saurabh Shrivastava
  • 1,091
  • 1
  • 8
  • 8
  • Hello, welcome to SO. Are you able to share the python code you have tried so far, and the exact error traceback? – Daniel Jul 29 '15 at 05:49

1 Answers1

0

Using two different types of quotes in your xpath will correct your SyntaxError:

a = self.driver.find_element_by_xpath('//*[@id="xyz"]/a')
a.click()

Check out this question for more info on using quotes within strings.

Community
  • 1
  • 1
Daniel
  • 2,345
  • 4
  • 19
  • 36