-
Notifications
You must be signed in to change notification settings - Fork 0
/
getJobDescriptionByIndex.js
34 lines (32 loc) · 1.19 KB
/
getJobDescriptionByIndex.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const waitElementAppera = require("./waitElementAppera");
const findElement = require("./findElement");
async function getJobDescriptionByIndex(index, webDriver, By) {
try {
const PositioningStrategyJobLi = By.xpath(
`//*[@id='wrap']/div[2]/div[2]/div/div/div[1]/ul/li[${index}]`
);
const jobLiElement = await webDriver.findElement(PositioningStrategyJobLi, webDriver, '招聘信息列表项');
// 点击招聘信息列表中的项
await jobLiElement.click();
// 找到描述信息节点并获取文字
const PositioningStrategyJobLiDescription = By.xpath(
"//*[@id='wrap']/div[2]/div[2]/div/div/div[2]/div/div[2]/p"
);
await waitElementAppera(
PositioningStrategyJobLiDescription,
webDriver,
until,
'职位描述信息'
);
const jobLiDescriptionElement = await findElement(
PositioningStrategyJobLiDescription,
webDriver,
'职位描述信息'
);
return jobLiDescriptionElement.getText();
} catch (error) {
// console.log(`在索引 ${index} 处找不到工作。`);
return Promise.reject(`${error}------且在索引 ${index} 处找不到工作。`);
}
}
module.exports = getJobDescriptionByIndex;