BMM1986 / selenium-vba

Automatically exported from code.google.com/p/selenium-vba
1 stars 0 forks source link

How could i clear the clip board #42

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Operating system and version (32/64bit) : 64
.Net Framework version :
Office name and version(32/64bit) : 64
Browser name and version :Google chrome
SeleniumWrapper version :latest version 

I was wanting to clear the clip board in my Google chrome window it seems to 
only paste the the first text i copied regardless of what was copied afterwards.

Was using the html code but it did not work on a certain text box. so i 
resorted to the shell.SendKey.

Original issue reported on code.google.com by CodyLeeG...@gmail.com on 14 Jan 2014 at 10:57

GoogleCodeExporter commented 8 years ago
Can you provide an example of what you are trying to achieve?
If it's just to clear the windows clipboard, you can use the toClipboad command 
:

Dim driver As New SeleniumWrapper.WebDriver
driver.Start "firefox", "http://www.google.com"
driver.Open "/"
...
driver.toClipboad ""

Original comment by florentbr on 15 Jan 2014 at 4:08

GoogleCodeExporter commented 8 years ago

Original comment by florentbr on 15 Jan 2014 at 4:09

GoogleCodeExporter commented 8 years ago
Sub Gamespot()

Dim driver As New SeleniumWrapper.WebDriver
Dim shell: Set shell = CreateObject("WScript.Shell")

    'I tab over to a combo text calendar widget , Because I cant find the elements name
shell.SendKeys "{TAB 22}"
    'I select the date i manually right down cell B1 to copy and paste in the combotext calender widget. This works great.
Sheets("Sheet1").Select
Application.CutCopyMode = False
Application.Sheets("Sheet1").Range("B1").Copy
shell.SendKeys "^v"
driver.Wait 1000

    'But when I try this same method over again exception being cell D1. It paste's the same as B1, which was copied previously.
Sheets("Sheet1").Select
Application.CutCopyMode = False
Application.Sheets("Sheet1").Range("D1").Copy
shell.SendKeys "{TAB 2}"
shell.SendKeys "^v"

    'I did go on to notice that after this ran threw it was on the correct range "D1" and it was highlighted that it was copied and if selected another cell in excel and pasted it would do the correct value. But if I were to click back into the same driver web page to paste it would paste what was previously pasted in the B1 Cell

I am curious if i could clear the clip board in driver before i copy my D1 
cell. If that would do the fix. I also wouldn't know how to do that, if you 
could walk me threw or if there are any other alternatives id be happy to hear.

Original comment by CodyLeeG...@gmail.com on 16 Jan 2014 at 6:28

GoogleCodeExporter commented 8 years ago
I wouldn't recommend to use the WScript.Shell to emulate the keyboard as it's 
not attached to the browser.
There's multiple ways to select a page element, like by id or with a Css 
selector and you can easily paste some text using the webdriver:

Dim driver As New SeleniumWrapper.WebDriver
Dim Keys As New SeleniumWrapper.Keys
driver.SendKeys String(22, Keys.Tab)
driver.toClipBoard Application.Sheets("Sheet1").Range("B1").Text
driver.Wait 500
driver.SendKeys Keys.Control & "v"
driver.Wait 500
...

I think you case is a timing issue. The cell text must still be on its way to 
the clipboard while you are trying to past it.
Try to had a wait command before sending the Ctrl+v.

Original comment by florentbr on 16 Jan 2014 at 10:15

GoogleCodeExporter commented 8 years ago
I got it to work with your advice where could i go to read more about Css. I 
seem to have problems plugging in data into DateTimePicker  and ComboBox'es.

Original comment by CodyLeeG...@gmail.com on 17 Jan 2014 at 1:20

GoogleCodeExporter commented 8 years ago
Here is some examples on Css locators :
http://www.natontesting.com/2011/09/24/css-locator-referencecheat-sheet-for-xpat
h-people/
http://software-testing-tutorials-automation.blogspot.co.uk/2013/06/selenium-css
-locators-tutorial-with.html

You can also select the Css in Selenium IDE once the action has been recorded 
and test some other by clicking on "Find"

The Selenium 1 format is :
driver.click "css=selector"
driver.type "css=selector", "text"
...

The Selenium 2 format is :
set ele = driver.findElementByCssSelector("selector")
ele.click
ele.sendKeys "text"

Original comment by florentbr on 17 Jan 2014 at 9:47

GoogleCodeExporter commented 8 years ago

Original comment by florentbr on 8 Sep 2014 at 5:40