2

I have to close the this dialog box

Dialog Box

The HTML Code of the same is

enter image description here

How to deal with it. There is no other option to close the dialog box. I have tried locating element via css selector but that dint help.

Edit CSS of ngdialog-close:before

.ngdialog.ngdialog-theme-default .ngdialog-close:before {
  background: transparent;
  border-radius: 3px;
  color: #bbb;
  content: '\00D7';
  font-size: 26px;
  font-weight: 400;
  height: 30px;
  line-height: 26px;
  position: absolute;
  right: 3px;
  text-align: center;
  top: 3px;
  width: 30px;
}
saurabh baid
  • 1,819
  • 1
  • 14
  • 26

2 Answers2

2

You can't click the ::before as it is not an element, it's probably content (If it is an element than someone used bad practices behind the scenes). Chrome displays it as ::before for debugging purposes. So I think it could be one of these:

  1. Either your close button isn't a button but an icon or a gif etc...
  2. You're missing the actual button which could be the div but it requires a hover before the click for example or it's a parent element to your div.
  3. Your button isn't working... (does it work manually?)

If it turns out it is an element, then you can click it with Chrome dev tools opened and see what the Styles tab is showing, for example:

div::before {
  content: url(some.gif);
} 

Perhaps it will show you the HTML code that's being added.

Moshisho
  • 2,781
  • 1
  • 23
  • 39
  • Your 2nd point got me going. I had to click on div but for some reason selenium `click()` was not working, even with the action chains. So I used javascript() click method and it solved my problem. – saurabh baid Feb 28 '17 at 09:10
  • That's great! and a little weird that it didn't work with Selenium... However, you can see in the `content: '\00D7';` that it's just a multiplication sign and not a button. (Unicode Character U+00D7) – Moshisho Feb 28 '17 at 09:25
0

U can use "Xpath". Probably isn't the best solution, but can work. Take a look:

Firstly, i create a function that wait:

def waitxpath(xpath_):
    element = WebDriverWait(driver, 15).until(
        EC.presence_of_element_located((By.XPATH, xpath_))
        )
    time.sleep(1)
    return element

After that, to click ok button "::before" u can use a code like that:

data_one = waitxpath('//*[@id="comunicado"]/span/i') driver.find_element(By.XPATH, '//*[@id="comunicado"]/span/i').click()

Well, i hope that it would be useful for u or anyone.

Page HTML: enter image description here

Dhytm
  • 1
  • 1