def open_custom_chrome(config, user_dir):chrome_option = Options()
chrome_option._experimental_options['prefs'] = config
chrome_option.add_argument("user-data-dir=" + user_dir)
driver = webdriver.Chrome(executable_path="C:/webdriver/32/chromedriver", chrome_options=chrome_option)
driver.get('http://www.google.com/')
--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.
Open Custom ChromeGo To ${inputUrl}///file.pydef open_custom_chrome():
lang = webdriver.ChromeOptions()
lang.add_argument("--lang=en")
chrome = webdriver.Chrome(chrome_options=lang)
chrome.get('http://www.google.com/xhtml')So, browser is opening and is going to google but Go To command can not be executed. Actualy error is :
| FAIL | No browser is open So, somehow something strange happens and robot can't see browser |
Ugh
You are almost getting it right, but you are missing few crucial parts. The main problem is that the webdriver instance only lives inside of that keyword and you must save the webdriver instance to the Selenium2Library instance (created by Robot Framework).
1) Get the S2L instance from Robot Framework [1].
2) Create the webdriver instance, like in your code.
3) Save the webdriver instance to the S2L instance. In S2L code, webdriver instance is usually referred as browser. There is not a public interface in S2L to save the webdriver instance, so you must rely on the private interface, but that has been stable for years and is safe to use. Read the Open Browser keyword code for good example how to save the webdriver instance.
If you encounter problems, don't hesitate to ask.
-Tatu
Send from my mobile
[1] http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#getting-active-library-instance-from-robot-framework
--
| Open URL in Google Chrome | [Arguments] | ${url}
| | [Documentation] | Starts the Google Chrome browser.
| | ${options}= | Evaluate | sys.modules['selenium.webdriver'].ChromeOptions() | sys
| | Call Method | ${options} | add_argument | --lang\=ru
| | Create WebDriver | Chrome | chrome_options=${options} | executable_path=C:/webdriver/32/chromedriver
| | Go To | ${url}
| | Maximize Browser Window
| | # and so onTo unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
${options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys
Call Method ${options} add_argument --user-data-dir\=C:/Users/.../Local/Google/Chrome/User Data
Create WebDriver Chrome chrome_options=${options} executable_path=C:/webdriver/32/chromedriver
Go To ${url}
*** Test Cases***
| Simple Test| | Open URL in Google Chrome | http://www.google.com| | Wait until Page Contains | xpath=//img[@title='Google']
| | # continue here with other Selenium2Library keywordsThat my code is directly located into Suite Setup
--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
Robot Framework remote server at 127.0.0.1:8270 starting.[PID:7740] EXECUTING createAndAcceptNotification[11012:3512:1118/072930:ERROR:cache_util_win.cc(20)] Unable to move the cache: 0[11012:3512:1118/072930:ERROR:cache_util.cc(132)] Unable to move cache folder C:\Users\iradovanovic\AppData\Local\Google\Chrome\User Data\ShaderCache\GPUCache to C:\Users\iradovanovic\AppData\Local\Google\Chrome\User Data\ShaderCache\old_GPUCache_000[11012:3512:1118/072930:ERROR:cache_creator.cc(132)] Unable to create cache[11012:3512:1118/072930:ERROR:shader_disk_cache.cc(588)] Shader Cache Creation failed: -2[PID:7740] still running createAndAcceptNotification after 15.0 seconds[PID:7740] still running createAndAcceptNotification after 30.0 seconds[PID:7740] still running createAndAcceptNotification after 45.0 seconds[PID:7740] still running createAndAcceptNotification after 60.0 secondsFAILED createAndAcceptNotification
*** Settings ***Documentation Restructured Testsuite
Resource testcases/notification/createAndAcceptNotification.robot
Variables resources/TestsysVar.py
Suite Setup SuiteConfiguration
Suite Teardown SuiteTeardown
*** Variables ***
*** Test Cases ***
Scenario: Create And Accept Custom Notification
[Tags] critical
TC-Create Custom Notification
*** Keywords ***
SuiteConfiguration
[Documentation] Open Browser and Login
${valuesetname}= Acquire Value Set
${browser}= Get Value From Set browser
${server}= Get Value From Set server
Set Suite Variable ${browser}
Set Suite Variable ${server}
${CC}= Get From Dictionary ${${server}} CC
${LIVE}= Get From Dictionary ${${server}} LIVE
${API}= Get From Dictionary ${${server}} API
${URL}= Get From Dictionary ${${server}} LOGIN
${options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys
Call Method ${options} add_argument user-data-dir\=C:/Users/iradovanovic/AppData/Local/Google/Chrome/User Data
Create WebDriver Chrome chrome chrome_options=${options} executable_path=C:/webdriver/32/chromedriver
${webdrive}= Get Webdriver Instance
Log ${webdrive}
Go To ${url}
Login @{customer}
Choose Authentication Profile 1
Confirm Password @{customer}[1]
Set Suite Variable ${CC}
Set Suite Variable ${LIVE}
Set Suite Variable ${API}
SuiteTeardown
[Documentation] When suite ends or fail
Close All Browsers
Release Value Set
Sure. Tnx for wanted to help.
Is like this.
.....
Call Method ${options} add_argument user-data-dir\=C:/Users/iradovanovic/AppData/Local/Google/Chrome/User Data
Please provide the log again after run with two --
Igor Radovanovic <igo...@gmail.com> schrieb am Mi., 18. Nov. 2015 um 15:24:
Ah, sorry. Yes. That was with --. Then i tried without and forget to revert. The behaviour is the same.--
On Wednesday, November 18, 2015 at 3:04:51 PM UTC+1, Tset Noitamotua wrote:First thing I would try:in this lineCall Method ${options} add_argument user-data-dir\=C:/Users/iradovanovic/AppData/Local/Google/Chrome/User Data
change user-date-dir\=... to --user-data-dir\=C:/Users/iradovanovic/AppData/Local/Google/Chrome/User DataNote the two -- before user-date-dirCheersTset
Am Mittwoch, 18. November 2015 07:49:30 UTC+1 schrieb Igor Radovanovic:Aham, so behavior is: Chrome will open - so no "default" chrome with profile User1, but will browser same look and config as if I would open NEW WINDOW from my current browser. But URL is EMPTY (also no: data; . as usually is in other cases )
On Wednesday, November 18, 2015 at 7:44:57 AM UTC+1, Igor Radovanovic wrote:Sure. Tnx for wanted to help.
Is like this......
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
On Wednesday, November 18, 2015 at 4:49:17 PM UTC+1, Tset Noitamotua wrote:Please provide the log again after run with two --Igor Radovanovic <igo...@gmail.com> schrieb am Mi., 18. Nov. 2015 um 15:24:
Ah, sorry. Yes. That was with --. Then i tried without and forget to revert. The behaviour is the same.--
On Wednesday, November 18, 2015 at 3:04:51 PM UTC+1, Tset Noitamotua wrote:First thing I would try:in this lineCall Method ${options} add_argument user-data-dir\=C:/Users/iradovanovic/AppData/Local/Google/Chrome/User Data
change user-date-dir\=... to --user-data-dir\=C:/Users/iradovanovic/AppData/Local/Google/Chrome/User DataNote the two -- before user-date-dirCheersTset
Am Mittwoch, 18. November 2015 07:49:30 UTC+1 schrieb Igor Radovanovic:Aham, so behavior is: Chrome will open - so no "default" chrome with profile User1, but will browser same look and config as if I would open NEW WINDOW from my current browser. But URL is EMPTY (also no: data; . as usually is in other cases )
On Wednesday, November 18, 2015 at 7:44:57 AM UTC+1, Igor Radovanovic wrote:Sure. Tnx for wanted to help.
Is like this......
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
Hmmm, you are using robot remote server, right? Have you tried to run local?
Igor Radovanovic <igo...@gmail.com> schrieb am Do., 19. Nov. 2015 um 08:39:
On Wednesday, November 18, 2015 at 4:49:17 PM UTC+1, Tset Noitamotua wrote:Please provide the log again after run with two --Igor Radovanovic <igo...@gmail.com> schrieb am Mi., 18. Nov. 2015 um 15:24:
Ah, sorry. Yes. That was with --. Then i tried without and forget to revert. The behaviour is the same.--
On Wednesday, November 18, 2015 at 3:04:51 PM UTC+1, Tset Noitamotua wrote:First thing I would try:in this lineCall Method ${options} add_argument user-data-dir\=C:/Users/iradovanovic/AppData/Local/Google/Chrome/User Data
change user-date-dir\=... to --user-data-dir\=C:/Users/iradovanovic/AppData/Local/Google/Chrome/User DataNote the two -- before user-date-dirCheersTset
Am Mittwoch, 18. November 2015 07:49:30 UTC+1 schrieb Igor Radovanovic:Aham, so behavior is: Chrome will open - so no "default" chrome with profile User1, but will browser same look and config as if I would open NEW WINDOW from my current browser. But URL is EMPTY (also no: data; . as usually is in other cases )
On Wednesday, November 18, 2015 at 7:44:57 AM UTC+1, Igor Radovanovic wrote:Sure. Tnx for wanted to help.
Is like this......
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.--
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.--
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
@echo off
REM ZEIT
set hour=%time:~0,2%
if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
set min=%time:~3,2%
if "%min:~0,1%" == " " set min=0%min:~1,1%
set secs=%time:~6,2%
if "%secs:~0,1%" == " " set secs=0%secs:~1,1%
REM DATUM
set year=%date:~-4%
set month=%date:~3,2%
if "%month:~0,1%" == " " set month=0%month:~1,1%
set day=%date:~0,2%
if "%day:~0,1%" == " " set day=0%day:~1,1%
REM Set DateTime
set datetimef=%year%%month%%day%_%hour%-%min%-%secs%
pybot --outputdir=results\%year%_%month%_%day%\TestRun_%datetimef% ^
--variable RESOURCES:GlobalyVar ^
--loglevel=TRACE ^
%*
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.--
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
*** Settings ***| Library | Selenium2Library
*** Variables ***| ${URL} | http://www.google.com
*** Test Cases ***| Simple Test| | Igors Keyword
*** Keywords ***| Igors Keyword| | [Documentation] | Open Browser and Login| | ${options}= | Evaluate | sys.modules['selenium.webdriver'].ChromeOptions() | sys| | Call Method | ${options} | add_argument | --user-data-dir\=C:/Users/username/AppData/Local/Google/Chrome/User Data| | Create WebDriver | Chrome | chrome_options=${options}| | Go To | ${url} |13:09:29.156 FAIL WebDriverException: Message: unknown error: Chrome failed to start: crashed
(Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067),platform=Windows NT 6.1 SP1 x86_64)
13:09:29.157 DEBUG Traceback (most recent call last):
File "<string>", line 2, in create_webdriver
File "C:\Python27\lib\site-packages\Selenium2Library\keywords\keywordgroup.py", line 15, in _run_on_failure_decorator
return method(*args, **kwargs)
File "C:\Python27\lib\site-packages\Selenium2Library\keywords\_browsermanagement.py", line 176, in create_webdriver
driver = creation_func(**init_kwargs)
File "C:\Python27\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 66, in __init__
keep_alive=True)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 87, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 136, in start_session
'desiredCapabilities': desired_capabilities,
File "C:\Python27\lib\site-packages\Selenium2Library\webdrivermonkeypatches.py", line 11, in execute
result = self._base_execute(driver_command, params)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 196, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 181, in check_response
raise exception_class(message, screen, stacktrace)
C:\_GITHUB\igor>pythonPython 2.7.9 (default, Dec 10 2014, 12:28:03) [MSC v.1500 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license" for more information.>>> from selenium import webdriver>>> option=webdriver.ChromeOptions()>>> option.add_argument("--user-data-dir=C:/Users/userxy/AppData/Local/Google/Chrome/User Data")>>> chrome = webdriver.Chrome(chrome_options=option)Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 66, in __init__ keep_alive=True) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 87, in __init__ self.start_session(desired_capabilities, browser_profile) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 136, in start_session 'desiredCapabilities': desired_capabilities, File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 196, in execute self.error_handler.check_response(response) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 181, in check_response raise exception_class(message, screen, stacktrace)selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed (Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067),platform=Windows NT 6.1 SP1 x86_64)
>>>*** Settings ***
| Library | Selenium2Library
*** Variables ***
| ${URL} | http://www.google.com
*** Test Cases ***
| Simple Test
| | Open Remote Chrome
*** Keywords ***
| Open Remote Chrome
| | [Documentation] | Open Remote Browser
| | ${options}= | Evaluate | sys.modules['selenium.webdriver'].ChromeOptions() | sys
| | Call Method | ${options} | add_argument | --user-data-dir\=C:/Users/userxy/AppData/Local/Google/Chrome/User Data
| | ${options} | Call Method | ${options} | to_capabilities
| | Create WebDriver | Remote | command_executor=http://hostname:4444/wd/hub | desired_capabilities=${options}
| | Go To | ${url}
--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.