使用editor.md插件后Selenium无法发送内容的问题

使用editor.md插件后无法发送内容的问题

思路

  1. 找到前边一个元素,
  2. 用Tab键切换到我想定位的editor.md元素,
  3. ele = self.driver.switch_to.active_element 获取当前激活的元素,
  4. ele 对象进行send_keys操作。

代码如下

@pytest.mark.posts
@allure.feature("文章feature测试")
class TestPosts(Base):
    """文章模块"""

    @allure.title("title添加文章测试")
    @allure.link("http://127.0.0.1:8000/admin/posts/post/add/")
    @allure.description("添加文章")
    @allure.severity(allure.severity_level.BLOCKER)
    @pytest.mark.parametrize('title, content, expected', Data.posts)
    def test_add_post(self, title, content, expected):
        self.driver.get("http://127.0.0.1:8000/admin/posts/post/add/")
        title_label = self.driver.find_element_by_id("id_title")
        title_label.send_keys(title)
        title_label.send_keys(Keys.TAB)
        ele = self.driver.switch_to.active_element
        ele.send_keys(content)
        self.driver.find_element_by_name("_save").click()

        assert expected in self.driver.title or expected in self.driver.find_element_by_class_name(
            "errornote").text

版权声明:
作者:Sunrise
链接:https://www.qlm.life/?p=245
来源:迷迭记录
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>