报错[object HTMLButtonElement] has no size and location

问题

页面中想定位弹窗中的关闭按钮,但是这个元素被伪元素包围,尝试用By_CSS_SEELECTOR方法和鼠标定位的方式,,都没有成功,鼠标定位后,报错是:
selenium.common.exception.ElementNotInteractableExpection:Message:element not interactable:[object HTMLButtonElement] has no size and location

前端代码如下:

	
<div class="modal fade poin-eventModal in" id="messageAlertObi" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: block;">
   <div class="modal-dialog" style="margin-top:383.5px;">
      <div class="modal-content">
         <divclass="modal-header">
            ::before
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button> 
            <spanclass="modal-title" id="messageAlertInfo">提示信息</span>
            ::after

pytho代码:

# 方法4:
close_action = ActionChains(self.driver)
ele_close = self.find(By.XPATH,'//*@id="messageAlert0bj"]/div/div/div[1]/button')
close_action.click(ele_close).perform()

报错信息

selenium.common.exception.ElementNotInteractableExpection:Message:element not interactable:[object HTMLButtonElement] has no size and location

打印下ele_close看下

这是后面加了.location后ele_close返回的结果

{'x':0, 'y':0}

后面加.size返回的结果是:

{'height':0, 'width':0}

不加.location返回结果是:

<selenium.webdriver.remote.webelement.WebElement(session="93be9ea0 a551c2ee9a516a790bac63b",element="9183f9ff-b82a-4132-b0d4-óa4ó69f80c91")>

感觉并没有定位到按钮的样子,可以看下页面的样子么

用手机传不了图片,:expressionless: ,要定位的x按钮在弹窗上的靠右上侧位置

这是谷歌浏览器自带的伪元素::before 和::after,,,,请问老师,可以怎么定位呢

可以用css选择器来定位,定位到伪元素的父元素再定位到伪元素

有没有试过js点击方法

看了下前端代码,,,这个伪元素的content是空的,所以看上去跟没定位上一样,,,这种情况下,,可以怎么定位呢

伪元素的父元素也定位不到,,css选择器用过了,,都是一样的效果,,都是定位不到

是哪一期的学员呀,可以远程么

远程不了,行内电脑不给连外网,:expressionless:

老师,可以加微信吗?我把图片发您

行吧,你是哪一期的学员呀,我看看我在群里没有,然后你再检查下你的定位表达式,在浏览器console中调试一下

5期的,console前几天就试了,可以定位到

我是助教-木木,你找下

草莓味的棉花糖??

图片发到群里也可以,其他老师一起帮忙

解决了,知道原因了,,问题出在iframe这里