Selenium 2: Detect content type of link destinations

后端 未结 3 1987
猫巷女王i
猫巷女王i 2021-01-15 19:16

I am using the Selenium 2 Java API to interact with web pages. My question is: How can i detect the content type of link destinations?

Basically, this is the backgro

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-15 20:08

    You can retrieve all the URLs from the DOM, and then parse the last few characters of each URL (using a java regex) to determine the link type.

    You can parse characters proceeding the last dot. For example, in the url http://yoursite.com/whatever/test.pdf, extract the pdf, and enforce your test logic accordingly.

    Am I oversimplifying your problem?

提交回复
热议问题