Jump to content

Autoit with wedriver-How to click on chrome tab


Recommended Posts

Greeting eveyrone!

I'm trying to use autoit with webdriver,but now I facing a big issue,I can't click the chrome tab(the meaning I want to click it is because if I right click on chrome's tab,there are some little function in them,I want to use some of them).So far I have try _WD_FindElement but it is outside the webpage so its even can't get a xpath,not to mention the _WD_ElementAction.So my plan just fail.

But if I get back to use coordinate,is a solution,but A BAD SOLUTION,cause if the window size change,everything fail,so I won't try this for sure.

Any guys got advice or hints for me?I just can't figure out if there's any solution for this scenario.Thanks in advance!

Link to post
Share on other sites
2 hours ago, Danp2 said:

This is vague. Please give exact details of the desired options that you want to access.

Hi Danp2,the function I want to use is called "Add Tab to New Group",which can be found when yon right click on any tab in chrome and under the list,it is listed in 3rd place.I do the research,there might not have any other way to call this function beside to use mouse.

So I try to use keyboard to replicate the mouse move

#include "wd_core.au3"
#include "wd_helper.au3"
#include "wd_capabilities.au3"
Local $sDesiredCapabilities
Local $account
Local $pwd
Local $value_for_account
Local $value_for_pwd
Local $login
Local $click_for_login

SetupChrome()
_WD_Startup()
_WD_ConsoleVisible(False)
$sSession1 = _WD_CreateSession($sDesiredCapabilities)
_WD_Window($sSession1,'MAXIMIZE')
_WD_Navigate($sSession1, "http://vbsca.ca/login/login.asp")
if _WD_LoadWait($sSession1) == 1 Then
  $account = _WD_FindElement($sSession1,$_WD_LOCATOR_ByXPath,"/html/body/form/table/tbody/tr[1]/td[2]/input")
  $value_for_account = _WD_ElementAction($sSession1, $account, "CLICK")
  Send("admin1")
  $pwd = _WD_FindElement($sSession1,$_WD_LOCATOR_ByXPath,"/html/body/form/table/tbody/tr[2]/td[2]/input")
  $value_for_pwd = _WD_ElementAction($sSession1, $pwd, "CLICK")
  Send("1234")
  $login = _WD_FindElement($sSession1,$_WD_LOCATOR_ByXPath,"/html/body/form/table/tbody/tr[3]/td[2]/input")
  $click_for_login = _WD_ElementAction($sSession1, $login, "CLICK" )
  #Move to the tab
  Send('{F6}')
  Send('{F6}')
  #Right click by using keyboard
  Send('+{F10}')
  #Choose the function "Add as group"
  Send('{DOWN}{DOWN}{DOWN}{ENTER}')
  #Give this tab a name and a color
  Send('123')
  Send('{ENTER}')
EndIf
_WD_ShutDown()
Func SetupChrome()
_WD_Option('Driver',"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\chromedriver.exe")
_WD_Option('Port', 9515)
;_WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"')
$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation", "enable-logging"]}}}}'

But it's not so reliable when I run it,and it didn't use webdriver.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...