0

I have one project and use selenium and chrome driver; I want use Ctrl + F in page and when open find bar type word in text box find bar and click in next or previous button in find bar; For open find bar i do this:

Robot robot = new Robot();
            robot.keyPress(KeyEvent.VK_CONTROL);
            robot.keyPress(KeyEvent.VK_F);

            robot.keyRelease(KeyEvent.VK_F);
            robot.keyRelease(KeyEvent.VK_CONTROL);

please help to continue

demouser123
  • 4,108
  • 9
  • 50
  • 82
Sobhan
  • 98
  • 11
  • 2
    Why would anyone want to do that ? – cruisepandey May 24 '21 at 14:21
  • Because i want to show word in page and next capture screenshot with java – Sobhan May 24 '21 at 14:28
  • Is it something like you want to write in excel file or PDF file ? – cruisepandey May 24 '21 at 14:52
  • Yes. when take screen shot i want to use in pdf file but i think is diffrent with write to pdf – Sobhan May 24 '21 at 14:57
  • 1
    You just want to highlight the word so it shows up in your screen shot? Should be fairly straight forward to do... – DMart May 24 '21 at 14:59
  • Are you able to get the web element ? – cruisepandey May 24 '21 at 15:12
  • 1
    Much better approach https://stackoverflow.com/questions/3401343/scroll-element-into-view-with-selenium. Just collect elements by text than scroll view and collect screenshots in a loop. – pburgr May 24 '21 at 15:12
  • Yes DMart.how can to do this? – Sobhan May 24 '21 at 15:13
  • i cant use element. Because site use this code: – Sobhan May 24 '21 at 15:36
  • embed id="plugin" type="application/x-google-chrome-pdf" src="https://www.pishkhan.com/Archive/1400/03/14000303/ArmanMeli651141109710948515150151.pdf" stream-url="chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/fb9307e6-3c6b-4e1b-8b15-4a0ac3053271" headers="accept-ranges: bytes cache-control: public, max-age=600,public content-length: 14264883 content-type: application/pdf date: Mon, 24 May 2021 15:30:26 GMT expires: Mon, 24 May 2021 15:40:26 GMT last-modified: Sun, 23 May 2021 19:46:48 GMT " background-color="4283586137" javascript="allow" full-frame="" pdf-viewer-update-enabled="" – Sobhan May 24 '21 at 15:36
  • looks like you've got it working... sending keys and hitting enter, and then enter again for next should do it... another alternative may be to just execute a javascript function... create one for HighLightText which takes the text as an argument. – pcalkins May 24 '21 at 17:31
  • Yes pcalkins.I can do it if i know the word,but when i got word from user, how can do this? – Sobhan May 25 '21 at 07:59
  • Please add more details to the question. Right now the question is very vague and doesn't explain what is the issue and what issue are you facing? This question is bound to be closed. – demouser123 Aug 03 '21 at 12:51

0 Answers0