Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 450 Vote(s) - 3.46 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pressing Ctrl + A in Selenium WebDriver

#11
Since <kbd>Ctrl</kbd>+<kbd>A</kbd> maps to ASCII code value 1 (<kbd>Ctrl</kbd>+<kbd>B</kbd> to 2, up to, <kbd>Ctrl</kbd>+<kbd>Z</kbd> to 26).

Try:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using OpenQA.Selenium;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Interactions;
using OpenQA.Selenium.Internal;
using OpenQA.Selenium.Remote;

namespace SeleniumHqTest
{
class Test
{
IWebDriver driver = new InternetExplorerDriver();
driver.Navigate().GoToUrl("http://localhost");
IWebElement el = driver.FindElement(By.Id("an_element_id"));
char c = '\u0001'; // ASCII code 1 for Ctrl-A
el.SendKeys(Convert.ToString©);
driver.Quit();
}
}
Reply

#12
To click <kbd>Ctrl</kbd>+<kbd>A</kbd>, you can do it with Actions

Actions action = new Actions();
action.keyDown(Keys.CONTROL).sendKeys(String.valueOf('\u0061')).perform();

\u0061 represents the character 'a'

\u0041 represents the character 'A'

To press other characters refer the unicode character table -
Reply

#13
It works for me:

OpenQA.Selenium.Interactions.Actions action
= new OpenQA.Selenium.Interactions.Actions(browser);
action.KeyDown(OpenQA.Selenium.Keys.Control)
.SendKeys("a").KeyUp(OpenQA.Selenium.Keys.Control).Perform();
Reply

#14
In Selenium for C#, sending `Keys.Control` simply toggles the **Control** key's state: if it's up, then it becomes down; if it's down, then it becomes up. So to simulate pressing **Control+A**, send `Keys.Control` twice, once before sending "a" and then after.

For example, if **we** is an input IWebElement, the following statement will select all of its contents:

`we.SendKeys(Keys.Control + "a" + Keys.Control);`
Reply

#15
WebDriver driver = new FirefoxDriver();

Actions action = new Actions(driver);

action.keyDown(Keys.CONTROL).sendKeys("a").keyUp(Keys.CONTROL).perform();

This method removes the extra call ( String.ValueOf() ) to convert unicode to string.
Reply

#16
You could try this:

driver.findElement(By.xpath(id("anything")).sendKeys(Keys.CONTROL + "a");
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through